Skip to content

Commit f3f3efe

Browse files
authored
Merge branch 'main' into fragment-args-2024-amendments
2 parents 4e0c6b6 + feac5a5 commit f3f3efe

6 files changed

+98
-40
lines changed

STYLE_GUIDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,8 @@ hyphens) should be capitalized, with the following exceptions:
5555
All elements in hyphenated words follow the same rules, e.g. headings may
5656
contain `Non-Null`, `Context-Free`, `Built-in` (`in` is a preposition, so is not
5757
capitalized).
58+
59+
## Lists
60+
61+
Lists can be written as full sentences or as fragments. Algorithms that appear
62+
as lists, however, should be written in full sentences with proper punctuation.

spec/Appendix B -- Grammar Summary.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ StringValue ::
100100

101101
- `""` [lookahead != `"`]
102102
- `"` StringCharacter+ `"`
103-
- `"""` BlockStringCharacter\* `"""`
103+
- BlockString
104104

105105
StringCharacter ::
106106

@@ -121,6 +121,8 @@ HexDigit :: one of
121121

122122
EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t`
123123

124+
BlockString :: `"""` BlockStringCharacter\* `"""`
125+
124126
BlockStringCharacter ::
125127

126128
- SourceCharacter but not `"""` or `\"""`

spec/Section 2 -- Language.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ StringValue ::
806806

807807
- `""` [lookahead != `"`]
808808
- `"` StringCharacter+ `"`
809-
- `"""` BlockStringCharacter\* `"""`
809+
- BlockString
810810

811811
StringCharacter ::
812812

@@ -827,6 +827,8 @@ HexDigit :: one of
827827

828828
EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t`
829829

830+
BlockString :: `"""` BlockStringCharacter\* `"""`
831+
830832
BlockStringCharacter ::
831833

832834
- SourceCharacter but not `"""` or `\"""`
@@ -1007,7 +1009,11 @@ StringCharacter :: `\` EscapedCharacter
10071009
| {`r`} | U+000D | carriage return |
10081010
| {`t`} | U+0009 | horizontal tab |
10091011

1010-
StringValue :: `"""` BlockStringCharacter\* `"""`
1012+
StringValue :: BlockString
1013+
1014+
- Return the _Unicode text_ by evaluating the {BlockString}.
1015+
1016+
BlockString :: `"""` BlockStringCharacter\* `"""`
10111017

10121018
- Let {rawValue} be the _Unicode text_ by concatenating the evaluation of all
10131019
{BlockStringCharacter} (which may be an empty sequence).
@@ -1114,7 +1120,7 @@ ListValue : [ Value+ ]
11141120
- For each {Value+}
11151121
- Let {value} be the result of evaluating {Value}.
11161122
- Append {value} to {inputList}.
1117-
- Return {inputList}
1123+
- Return {inputList}.
11181124

11191125
### Input Object Values
11201126

@@ -1162,7 +1168,7 @@ ObjectValue : { ObjectField+ }
11621168
- Let {name} be {Name} in {field}.
11631169
- Let {value} be the result of evaluating {Value} in {field}.
11641170
- Add a field to {inputObject} of name {name} containing value {value}.
1165-
- Return {inputObject}
1171+
- Return {inputObject}.
11661172

11671173
## Variables
11681174

spec/Section 3 -- Type System.md

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ RootOperationTypeDefinition : OperationType : NamedType
122122

123123
A GraphQL service's collective type system capabilities are referred to as that
124124
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,
126126
mutation, and subscription; this determines the place in the type system where
127127
those 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
146146
type 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
151151
service does not support mutations. If it is provided, it must be an Object
152152
type.
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
155155
not provided, the service does not support subscriptions. If it is provided, it
156156
must be an Object type.
157157

158158
The {`query`}, {`mutation`}, and {`subscription`} root types must all be
159159
different 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
162162
available at the top level of a GraphQL query operation.
163163

164164
For 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
175176
type 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
184185
mutation {
@@ -191,8 +192,8 @@ mutation {
191192
When using the type system definition language, a document must include at most
192193
one {`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
198199
schema {
@@ -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

219223
Likewise, 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

223228
This example describes a valid complete GraphQL schema, despite not explicitly
224229
including 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
228233
type 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

235264
SchemaExtension :
@@ -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

330359
IsOutputType(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
406435
scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122")
407436
scalar URL @specifiedBy(url: "https://tools.ietf.org/html/rfc3986")
437+
scalar DateTime
438+
@specifiedBy(url: "https://scalars.graphql.org/andimarek/date-time")
408439
```
409440

410441
Custom *scalar specification URL*s should provide a single, stable format to
411442
avoid ambiguity. If the linked specification is in flux, the service should link
412443
to 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+
414448
Custom *scalar specification URL*s should not be changed once defined. Doing so
415449
would likely disrupt tooling or could introduce breaking changes within the
416450
linked specification's contents.
@@ -419,7 +453,9 @@ Built-in scalar types must not provide a _scalar specification URL_ as they are
419453
specified by this document.
420454

421455
Note: 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.
885923
3. An object type may declare that it implements one or more unique interfaces.
886924
4. 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}.
12331273
3. 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

17581798
Fields 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

17621803
Inputs (such as field arguments), are always optional by default. However a
17631804
non-null input type is required. In addition to not accepting the value {null},
@@ -2004,7 +2045,9 @@ repeatable directives.
20042045
4. 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
21102153
point to a human-readable specification of the data format, serialization, and
21112154
coercion 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+
21132159
In this example, a custom scalar type for `UUID` is defined with a URL pointing
21142160
to the relevant IETF specification.
21152161

spec/Section 5 -- Validation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ ambiguous and invalid.
810810
which contains {argument}.
811811
- {arguments} must be the set containing only {argument}.
812812

813-
#### Required Arguments
813+
### Required Arguments
814814

815815
- For each Field, Fragment Spread or Directive in the document:
816816
- Let {arguments} be the arguments provided by the Field, Directive or
@@ -1086,7 +1086,7 @@ is a validation error if the target of a spread is not defined.
10861086

10871087
- For each {fragmentDefinition} in the document:
10881088
- Let {visited} be the empty set.
1089-
- {DetectFragmentCycles(fragmentDefinition, visited)}
1089+
- {DetectFragmentCycles(fragmentDefinition, visited)}.
10901090

10911091
DetectFragmentCycles(fragmentDefinition, visited):
10921092

@@ -1095,7 +1095,7 @@ DetectFragmentCycles(fragmentDefinition, visited):
10951095
- {visited} must not contain {spread}.
10961096
- Let {nextVisited} be the set including {spread} and members of {visited}.
10971097
- Let {nextFragmentDefinition} be the target of {spread}.
1098-
- {DetectFragmentCycles(nextFragmentDefinition, nextVisited)}
1098+
- {DetectFragmentCycles(nextFragmentDefinition, nextVisited)}.
10991099

11001100
**Explanatory Text**
11011101

spec/Section 6 -- Execution.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,8 @@ must receive no more events from that event stream.
224224

225225
**Supporting Subscriptions at Scale**
226226

227-
Supporting subscriptions is a significant change for any GraphQL service. Query
228-
and mutation operations are stateless, allowing scaling via cloning of GraphQL
229-
service instances. Subscriptions, by contrast, are stateful and require
227+
Query and mutation operations are stateless, allowing scaling via cloning of
228+
GraphQL service instances. Subscriptions, by contrast, are stateful and require
230229
maintaining the GraphQL document, variables, and other context over the lifetime
231230
of the subscription.
232231

@@ -264,7 +263,7 @@ CreateSourceEventStream(subscription, schema, variableValues, initialValue):
264263
is unaffected if an alias is used.
265264
- Let {field} be the first entry in {fields}.
266265
- Let {argumentValues} be the result of {CoerceArgumentValues(subscriptionType,
267-
field, variableValues)}
266+
field, variableValues)}.
268267
- Let {fieldStream} be the result of running
269268
{ResolveFieldEventStream(subscriptionType, initialValue, fieldName,
270269
argumentValues)}.

0 commit comments

Comments
 (0)