@@ -122,7 +122,7 @@ RootOperationTypeDefinition : OperationType : NamedType
122122
123123A GraphQL service's collective type system capabilities are referred to as that
124124service'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,
126126mutation, and subscription; this determines the place in the type system where
127127those operations begin.
128128
@@ -141,24 +141,24 @@ introspection system.
141141
142142### Root Operation Types
143143
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
146146type system where those operations begin.
147147
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.
149149
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
151151service does not support mutations. If it is provided, it must be an Object
152152type.
153153
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
155155not provided, the service does not support subscriptions. If it is provided, it
156156must be an Object type.
157157
158158The {` query ` }, {` mutation ` }, and {` subscription ` } root types must all be
159159different types if provided.
160160
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
162162available at the top level of a GraphQL query operation.
163163
164164For example, this example operation:
@@ -169,16 +169,17 @@ query {
169169}
170170```
171171
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":
173174
174175``` graphql example
175176type Query {
176177 myName : String
177178}
178179```
179180
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" .
182183
183184```graphql example
184185mutation {
@@ -191,8 +192,8 @@ mutation {
191192When using the type system definition language, a document must include at most
192193one {` schema ` } definition.
193194
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 _ :
196197
197198``` graphql example
198199schema {
@@ -211,25 +212,53 @@ type MyMutationRootType {
211212
212213**Default Root Operation Type Names **
213214
214- While any type can be the root operation type for a GraphQL operation , the type
215- system definition language can omit the schema definition when the {`query`},
216- {`mutation `}, and {`subscription `} root types are named {"Query" }, {"Mutation" },
217- 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 .
218+
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_.
218222
219223Likewise, when representing a GraphQL schema using the type system definition
220- language, a schema definition should be omitted if it only uses the default root
221- operation type names.
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_.
222227
223228This example describes a valid complete GraphQL schema, despite not explicitly
224229including a {`schema`} definition . The {"Query" } type is presumed to be the
225- {`query `} root operation type of the schema .
230+ {`query `} _root operation type_ of the schema .
226231
227232```graphql example
228233type Query {
229234 someField : String
230235}
231236```
232237
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+
233262### Schema Extension
234263
235264SchemaExtension :
@@ -325,7 +354,7 @@ IsInputType(type) :
325354 - Return IsInputType ({unwrappedType})
326355- If {type } is a Scalar , Enum , or Input Object type :
327356 - Return {true }
328- - Return {false}
357+ - Return {false }.
329358
330359IsOutputType (type) :
331360
@@ -334,7 +363,7 @@ IsOutputType(type) :
334363 - Return IsOutputType ({unwrappedType})
335364- If {type } is a Scalar , Object , Interface , Union , or Enum type :
336365 - Return {true }
337- - Return {false}
366+ - Return {false }.
338367
339368### Type Extensions
340369
@@ -405,12 +434,17 @@ conform to its described rules.
405434```graphql example
406435scalar UUID @specifiedBy (url : " https://tools.ietf.org/html/rfc4122" )
407436scalar URL @specifiedBy (url : " https://tools.ietf.org/html/rfc3986" )
437+ scalar DateTime
438+ @specifiedBy (url : " https://scalars.graphql.org/andimarek/date-time" )
408439```
409440
410441Custom *scalar specification URL*s should provide a single, stable format to
411442avoid ambiguity. If the linked specification is in flux, the service should link
412443to a fixed version rather than to a resource which might change.
413444
445+ Note: Some community-maintained custom scalar specifications are hosted at
446+ [scalars.graphql.org](https://scalars.graphql.org/).
447+
414448Custom *scalar specification URL*s should not be changed once defined. Doing so
415449would likely disrupt tooling or could introduce breaking changes within the
416450linked specification's contents.
@@ -419,7 +453,9 @@ Built-in scalar types must not provide a _scalar specification URL_ as they are
419453specified by this document.
420454
421455Note: Custom scalars should also summarize the specified format and provide
422- examples in their description .
456+ examples in their description; see the GraphQL scalars
457+ [implementation guide](https://scalars.graphql.org/implementation-guide) for
458+ more guidance.
423459
424460**Result Coercion and Serialization**
425461
@@ -878,9 +914,11 @@ of rules must be adhered to by every Object type in a GraphQL schema.
878914 4. For each argument of the field :
879915 1. The argument must not have a name which begins with the characters
880916 {"\_\_" } (two underscores).
881- 2. The argument must accept a type where {IsInputType (argumentType)}
917+ 2. The argument must have a unique name within that field ; no two
918+ arguments may share the same name .
919+ 3. The argument must accept a type where {IsInputType (argumentType)}
882920 returns {true }.
883- 3 . If argument type is Non -Null and a default value is not defined :
921+ 4 . If argument type is Non -Null and a default value is not defined :
884922 - The `@deprecated ` directive must not be applied to this argument .
8859233. An object type may declare that it implements one or more unique interfaces .
8869244. An object type must be a super -set of all interfaces it implements :
@@ -1228,7 +1266,9 @@ Interface types have the potential to be invalid if incorrectly defined.
12281266 4. For each argument of the field :
12291267 1. The argument must not have a name which begins with the characters
12301268 {"\_\_" } (two underscores).
1231- 2. The argument must accept a type where {IsInputType (argumentType)}
1269+ 2. The argument must have a unique name within that field ; no two
1270+ arguments may share the same name .
1271+ 3. The argument must accept a type where {IsInputType (argumentType)}
12321272 returns {true }.
123312733. An interface type may declare that it implements one or more unique
12341274 interfaces , but may not implement itself .
@@ -1756,8 +1796,9 @@ to denote a field that uses a Non-Null type like this: `name: String!`.
17561796**Nullable vs . Optional **
17571797
17581798Fields are _always_ optional within the context of a selection set , a field may
1759- be omitted and the selection set is still valid . However fields that return
1760- Non -Null types will never return the value {null } if queried .
1799+ be omitted and the selection set is still valid (so long as the selection set
1800+ does not become empty). However fields that return Non -Null types will never
1801+ return the value {null } if queried .
17611802
17621803Inputs (such as field arguments), are always optional by default . However a
17631804non -null input type is required . In addition to not accepting the value {null },
@@ -2004,7 +2045,9 @@ repeatable directives.
200420454. For each argument of the directive :
20052046 1. The argument must not have a name which begins with the characters
20062047 {"\_\_" } (two underscores).
2007- 2. The argument must accept a type where {IsInputType (argumentType)} returns
2048+ 2. The argument must have a unique name within that directive ; no two
2049+ arguments may share the same name .
2050+ 3. The argument must accept a type where {IsInputType (argumentType)} returns
20082051 {true }.
20092052
20102053### @skip
@@ -2110,6 +2153,9 @@ behavior of [custom scalar types](#sec-Scalars.Custom-Scalars). The URL should
21102153point to a human-readable specification of the data format, serialization, and
21112154coercion rules. It must not appear on built-in scalar types.
21122155
2156+ Note : Details on implementing a GraphQL scalar specification can be found in the
2157+ [scalars .graphql .org implementation guide ](https ://scalars .graphql .org /implementation -guide ).
2158+
21132159In this example , a custom scalar type for `UUID ` is defined with a URL pointing
21142160to the relevant IETF specification .
21152161
0 commit comments