Skip to content

Commit ee9c191

Browse files
committed
Enable 'schema' keyword to be provided without root operations
1 parent 692d811 commit ee9c191

File tree

2 files changed

+47
-13
lines changed

2 files changed

+47
-13
lines changed

spec/Appendix B -- Grammar Summary.md

+5-2
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

+42-11
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,23 @@ 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_,
231+
- the schema does not have a description, and
232+
- the schema uses the {"PROPAGATE"} _default error behavior_.
222233

223234
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_.
235+
language, a schema definition should be omitted if all of the above conditions
236+
hold; otherwise the schema definition's root operation type definitions should
237+
be omitted if each _root operation type_ uses its respective _default root type
238+
name_ and no other type uses any _default root type name_.
227239

228240
This example describes a valid complete GraphQL schema, despite not explicitly
229241
including a {`schema`} definition. The {"Query"} type is presumed to be the
@@ -259,6 +271,27 @@ type Mutation {
259271
}
260272
```
261273

274+
<!-- https://github.com/prettier/prettier/issues/17286 -->
275+
<!-- prettier-ignore -->
276+
This example describes a valid GraphQL schema with a description, _default
277+
error behavior_ of {"NO\_PROPAGATE"}, and both a {`query`} and {`mutation`}
278+
operation type:
279+
280+
```graphql example
281+
"""
282+
Example schema
283+
"""
284+
schema @behavior(onError: NO_PROPAGATE)
285+
286+
type Query {
287+
someField: String
288+
}
289+
290+
type Mutation {
291+
someMutation: String
292+
}
293+
```
294+
262295
### Schema Extension
263296

264297
SchemaExtension :
@@ -2187,7 +2220,5 @@ In this example, the schema indicates it is using the {"NO\_PROPAGATE"} _default
21872220
error behavior_:
21882221

21892222
```graphql example
2190-
schema @behavior(onError: NO_PROPAGATE) {
2191-
query: Query
2192-
}
2223+
schema @behavior(onError: NO_PROPAGATE)
21932224
```

0 commit comments

Comments
 (0)