From 75dc26ab7f7872632a3ac79bcb1b19db36c015de Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Wed, 30 Apr 2025 12:39:37 +0100 Subject: [PATCH 1/2] Enable 'schema' keyword to be provided without root operations --- spec/Appendix B -- Grammar Summary.md | 7 +++-- spec/Section 3 -- Type System.md | 45 ++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/spec/Appendix B -- Grammar Summary.md b/spec/Appendix B -- Grammar Summary.md index 92f222cb3..40c41ef79 100644 --- a/spec/Appendix B -- Grammar Summary.md +++ b/spec/Appendix B -- Grammar Summary.md @@ -258,8 +258,11 @@ TypeSystemExtension : - SchemaExtension - TypeExtension -SchemaDefinition : Description? schema Directives[Const]? { -RootOperationTypeDefinition+ } +SchemaDefinition : + +- Description? schema Directives[Const]? { RootOperationTypeDefinition+ } +- Description? schema Directives[Const] [lookahead != `{`] +- Description schema [lookahead != {`{`, `@`}] SchemaExtension : diff --git a/spec/Section 3 -- Type System.md b/spec/Section 3 -- Type System.md index 81d377cf3..5bdbce8cc 100644 --- a/spec/Section 3 -- Type System.md +++ b/spec/Section 3 -- Type System.md @@ -115,8 +115,11 @@ enum Language { ## Schema -SchemaDefinition : Description? schema Directives[Const]? { -RootOperationTypeDefinition+ } +SchemaDefinition : + +- Description? schema Directives[Const]? { RootOperationTypeDefinition+ } +- Description? schema Directives[Const] [lookahead != `{`] +- Description schema [lookahead != {`{`, `@`}] RootOperationTypeDefinition : OperationType : NamedType @@ -216,14 +219,22 @@ type MyMutationRootType { {`subscription`} _root operation type_ are {"Query"}, {"Mutation"}, and {"Subscription"} respectively. -The type system definition language can omit the schema definition when each -_root operation type_ uses its respective _default root type name_ and no other -type uses any _default root type name_. +The type system definition language can omit the schema definition's root +operation type definitions when each _root operation type_ uses its respective +_default root type name_ and no other type uses any _default root type name_. + +The type system definition language can omit the schema definition entirely when +all of the following hold: + +- each _root operation type_ uses its respective _default root type name_, +- no other type uses any _default root type name_, and +- the schema does not have a description. Likewise, when representing a GraphQL schema using the type system definition -language, a schema definition should be omitted if each _root operation type_ -uses its respective _default root type name_ and no other type uses any _default -root type name_. +language, a schema definition should be omitted if all of the above conditions +hold; otherwise the schema definition's root operation type definitions should +be omitted if each _root operation type_ uses its respective _default root type +name_ and no other type uses any _default root type name_. This example describes a valid complete GraphQL schema, despite not explicitly including a {`schema`} definition. The {"Query"} type is presumed to be the @@ -259,6 +270,24 @@ type Mutation { } ``` +This example describes a valid GraphQL schema with a description and both a +{`query`} and {`mutation`} operation type: + +```graphql example +""" +Example schema +""" +schema + +type Query { + someField: String +} + +type Mutation { + someMutation: String +} +``` + ### Schema Extension SchemaExtension : From c68c09ba39d66236c965af228a5fd0b9e7f34974 Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Thu, 1 May 2025 10:52:38 +0100 Subject: [PATCH 2/2] Apply changes for error behavior --- spec/Section 3 -- Type System.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/spec/Section 3 -- Type System.md b/spec/Section 3 -- Type System.md index 5bdbce8cc..b2b0280d5 100644 --- a/spec/Section 3 -- Type System.md +++ b/spec/Section 3 -- Type System.md @@ -227,8 +227,9 @@ The type system definition language can omit the schema definition entirely when all of the following hold: - each _root operation type_ uses its respective _default root type name_, -- no other type uses any _default root type name_, and -- the schema does not have a description. +- no other type uses any _default root type name_, +- the schema does not have a description, and +- the schema uses the {"PROPAGATE"} _default error behavior_. Likewise, when representing a GraphQL schema using the type system definition language, a schema definition should be omitted if all of the above conditions @@ -270,14 +271,17 @@ type Mutation { } ``` -This example describes a valid GraphQL schema with a description and both a -{`query`} and {`mutation`} operation type: + + +This example describes a valid GraphQL schema with a description, _default +error behavior_ of {"NO\_PROPAGATE"}, and both a {`query`} and {`mutation`} +operation type: ```graphql example """ Example schema """ -schema +schema @behavior(onError: NO_PROPAGATE) type Query { someField: String @@ -2216,7 +2220,5 @@ In this example, the schema indicates it is using the {"NO\_PROPAGATE"} _default error behavior_: ```graphql example -schema @behavior(onError: NO_PROPAGATE) { - query: Query -} +schema @behavior(onError: NO_PROPAGATE) ```