Skip to content

Commit 470358c

Browse files
committed
Enable 'schema' keyword to be provided without root operations
1 parent dc7b27e commit 470358c

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

spec/Appendix B -- Grammar Summary.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,11 @@ TypeSystemExtension :
258258
- SchemaExtension
259259
- TypeExtension
260260

261-
SchemaDefinition : Description? schema Directives[Const]? {
262-
RootOperationTypeDefinition+ }
261+
SchemaDefinition :
262+
263+
- Description? schema Directives[Const]? { RootOperationTypeDefinition+ }
264+
- Description? schema Directives[Const] [lookahead != `{`]
265+
- Description schema [lookahead != {`{`, `@`}]
263266

264267
SchemaExtension :
265268

spec/Section 3 -- Type System.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@ enum Language {
115115

116116
## Schema
117117

118-
SchemaDefinition : Description? schema Directives[Const]? {
119-
RootOperationTypeDefinition+ }
118+
SchemaDefinition :
119+
120+
- Description? schema Directives[Const]? { RootOperationTypeDefinition+ }
121+
- Description? schema Directives[Const] [lookahead != `{`]
122+
- Description schema [lookahead != {`{`, `@`}]
120123

121124
RootOperationTypeDefinition : OperationType : NamedType
122125

@@ -216,14 +219,22 @@ type MyMutationRootType {
216219
{`subscription`} _root operation type_ are {"Query"}, {"Mutation"}, and
217220
{"Subscription"} respectively.
218221

219-
The type system definition language can omit the schema definition when each
220-
_root operation type_ uses its respective _default root type name_ and no other
221-
type uses any _default root type name_.
222+
The type system definition language can omit the schema definition's root
223+
operation type definitions when each _root operation type_ uses its respective
224+
_default root type name_ and no other type uses any _default root type name_.
225+
226+
The type system definition language can omit the schema definition entirely when
227+
all of the following hold:
228+
229+
- each _root operation type_ uses its respective _default root type name_,
230+
- no other type uses any _default root type name_, and
231+
- the schema does not have a description.
222232

223233
Likewise, when representing a GraphQL schema using the type system definition
224-
language, a schema definition should be omitted if each _root operation type_
225-
uses its respective _default root type name_ and no other type uses any _default
226-
root type name_.
234+
language, a schema definition should be omitted if all of the above conditions
235+
hold; otherwise the schema definition's root operation type definitions should
236+
be omitted if each _root operation type_ uses its respective _default root type
237+
name_ and no other type uses any _default root type name_.
227238

228239
This example describes a valid complete GraphQL schema, despite not explicitly
229240
including a {`schema`} definition. The {"Query"} type is presumed to be the
@@ -259,6 +270,24 @@ type Mutation {
259270
}
260271
```
261272

273+
This example describes a valid GraphQL schema with a description and both a
274+
{`query`} and {`mutation`} operation type:
275+
276+
```graphql example
277+
"""
278+
Example schema
279+
"""
280+
schema
281+
282+
type Query {
283+
someField: String
284+
}
285+
286+
type Mutation {
287+
someMutation: String
288+
}
289+
```
290+
262291
### Schema Extension
263292

264293
SchemaExtension :

0 commit comments

Comments
 (0)