@@ -122,7 +122,7 @@ RootOperationTypeDefinition : OperationType : NamedType
122
122
123
123
A GraphQL service's collective type system capabilities are referred to as that
124
124
service's "schema". A schema is defined in terms of the types and directives it
125
- supports as well as the root operation types for each kind of operation: query,
125
+ supports as well as the _ root operation type _ for each kind of operation: query,
126
126
mutation, and subscription; this determines the place in the type system where
127
127
those operations begin.
128
128
@@ -141,24 +141,24 @@ introspection system.
141
141
142
142
### Root Operation Types
143
143
144
- A schema defines the initial root operation type for each kind of operation it
145
- supports: query, mutation, and subscription; this determines the place in the
144
+ :: A schema defines the initial _ root operation type _ for each kind of operation
145
+ it supports: query, mutation, and subscription; this determines the place in the
146
146
type system where those operations begin.
147
147
148
- The {` query ` } root operation type must be provided and must be an Object type.
148
+ The {` query ` } _ root operation type _ must be provided and must be an Object type.
149
149
150
- The {` mutation ` } root operation type is optional; if it is not provided, the
150
+ The {` mutation ` } _ root operation type _ is optional; if it is not provided, the
151
151
service does not support mutations. If it is provided, it must be an Object
152
152
type.
153
153
154
- Similarly, the {` subscription ` } root operation type is also optional; if it is
154
+ Similarly, the {` subscription ` } _ root operation type _ is also optional; if it is
155
155
not provided, the service does not support subscriptions. If it is provided, it
156
156
must be an Object type.
157
157
158
158
The {` query ` }, {` mutation ` }, and {` subscription ` } root types must all be
159
159
different types if provided.
160
160
161
- The fields on the {` query ` } root operation type indicate what fields are
161
+ The fields on the {` query ` } _ root operation type _ indicate what fields are
162
162
available at the top level of a GraphQL query operation.
163
163
164
164
For example, this example operation:
@@ -169,16 +169,17 @@ query {
169
169
}
170
170
```
171
171
172
- is only valid when the {` query ` } root operation type has a field named "myName":
172
+ is only valid when the {` query ` } _ root operation type_ has a field named
173
+ "myName":
173
174
174
175
``` graphql example
175
176
type Query {
176
177
myName : String
177
178
}
178
179
```
179
180
180
- Similarly , the following mutation is only valid if the {`mutation `} root
181
- operation type has a field named "setName" .
181
+ Similarly , the following mutation is only valid if the {`mutation `} _root
182
+ operation type_ has a field named "setName" .
182
183
183
184
```graphql example
184
185
mutation {
@@ -191,8 +192,8 @@ mutation {
191
192
When using the type system definition language, a document must include at most
192
193
one {` schema ` } definition.
193
194
194
- In this example, a GraphQL schema is defined with both query and mutation root
195
- operation types :
195
+ In this example, a GraphQL schema is defined with both a query and mutation
196
+ _ root operation type _ :
196
197
197
198
``` graphql example
198
199
schema {
@@ -211,29 +212,53 @@ type MyMutationRootType {
211
212
212
213
**Default Root Operation Type Names **
213
214
214
- :: While any type can be the root operation type for a GraphQL operation , the
215
- _default root type name_ for the {` query ` }, {` mutation ` }, and {` subscription `}
216
- root types are { "Query" }, { "Mutation" }, and {"Subscription" } respectively .
215
+ :: The _default root type name_ for each {` query `}, {` mutation `}, and
216
+ {` subscription `} _root operation type_ are { "Query" }, {"Mutation" }, and
217
+ {"Subscription" } respectively .
217
218
218
219
The type system definition language can omit the schema definition when each
219
- root type present uses its respective _default root type name_ and no other type
220
- uses a default root type name .
220
+ _root operation type_ uses its respective _default root type name_ and no other
221
+ type uses any _default root type name_ .
221
222
222
223
Likewise, when representing a GraphQL schema using the type system definition
223
- language, a schema definition should be omitted if each root type present uses
224
- its respective _default root type name_ and no other type uses a default root
225
- type name .
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_ .
226
227
227
228
This example describes a valid complete GraphQL schema, despite not explicitly
228
229
including a {`schema`} definition . The {"Query" } type is presumed to be the
229
- {`query `} root operation type of the schema .
230
+ {`query `} _root operation type_ of the schema .
230
231
231
232
```graphql example
232
233
type Query {
233
234
someField : String
234
235
}
235
236
```
236
237
238
+ This example describes a valid GraphQL schema without a {` mutation ` } _ root
239
+ operation type_ , even though it contains a type named {"Mutation"}. The schema
240
+ definition must be included, otherwise the {"Mutation"} type would be
241
+ incorrectly presumed to be the {` mutation ` } _ root operation type_ of the schema.
242
+
243
+ ``` graphql example
244
+ schema {
245
+ query : Query
246
+ }
247
+
248
+ type Query {
249
+ latestVirus : Virus
250
+ }
251
+
252
+ type Virus {
253
+ name : String
254
+ mutations : [Mutation ]
255
+ }
256
+
257
+ type Mutation {
258
+ name : String
259
+ }
260
+ ```
261
+
237
262
### Schema Extension
238
263
239
264
SchemaExtension :
0 commit comments