Skip to content

Commit a1de2dd

Browse files
committed
Merge branch 'main' into benjie/incremental-common
2 parents 60a9c35 + 2073bc8 commit a1de2dd

File tree

5 files changed

+89
-62
lines changed

5 files changed

+89
-62
lines changed

spec/Section 2 -- Language.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ There are three types of operations that GraphQL models:
288288

289289
- query - a read-only fetch.
290290
- mutation - a write followed by a fetch.
291-
- subscription - a long-lived request that fetches data in response to source
292-
events.
291+
- subscription - a long-lived request that fetches data in response to a
292+
sequence of events over time.
293293

294294
Each operation is represented by an optional operation name and a _selection
295295
set_.

spec/Section 3 -- Type System.md

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ TypeSystemExtension :
4242
- TypeExtension
4343

4444
Type system extensions are used to represent a GraphQL type system which has
45-
been extended from some original type system. For example, this might be used by
45+
been extended from some previous type system. For example, this might be used by
4646
a local service to represent data a GraphQL client only accesses locally, or by
4747
a GraphQL service which is itself an extension of another GraphQL service.
4848

@@ -266,8 +266,8 @@ SchemaExtension :
266266
- extend schema Directives[Const]? { RootOperationTypeDefinition+ }
267267
- extend schema Directives[Const] [lookahead != `{`]
268268

269-
Schema extensions are used to represent a schema which has been extended from an
270-
original schema. For example, this might be used by a GraphQL service which adds
269+
Schema extensions are used to represent a schema which has been extended from a
270+
previous schema. For example, this might be used by a GraphQL service which adds
271271
additional operation types, or additional directives to an existing schema.
272272

273273
Note: Schema extensions without additional operation type definitions must not
@@ -279,7 +279,7 @@ The same limitation applies to the type definitions and extensions below.
279279
Schema extensions have the potential to be invalid if incorrectly defined.
280280

281281
1. The Schema must already be defined.
282-
2. Any non-repeatable directives provided must not already apply to the original
282+
2. Any non-repeatable directives provided must not already apply to the previous
283283
Schema.
284284

285285
## Types
@@ -377,7 +377,7 @@ TypeExtension :
377377
- InputObjectTypeExtension
378378

379379
Type extensions are used to represent a GraphQL type which has been extended
380-
from some original type. For example, this might be used by a local service to
380+
from some previous type. For example, this might be used by a local service to
381381
represent additional fields a GraphQL client only accesses locally.
382382

383383
## Scalars
@@ -640,15 +640,15 @@ ScalarTypeExtension :
640640
- extend scalar Name Directives[Const]
641641

642642
Scalar type extensions are used to represent a scalar type which has been
643-
extended from some original scalar type. For example, this might be used by a
643+
extended from some previous scalar type. For example, this might be used by a
644644
GraphQL tool or service which adds directives to an existing scalar.
645645

646646
**Type Validation**
647647

648648
Scalar type extensions have the potential to be invalid if incorrectly defined.
649649

650650
1. The named type must already be defined and must be a Scalar type.
651-
2. Any non-repeatable directives provided must not already apply to the original
651+
2. Any non-repeatable directives provided must not already apply to the previous
652652
Scalar type.
653653

654654
## Objects
@@ -1048,7 +1048,7 @@ ObjectTypeExtension :
10481048
- extend type Name ImplementsInterfaces [lookahead != `{`]
10491049

10501050
Object type extensions are used to represent a type which has been extended from
1051-
some original type. For example, this might be used to represent local data, or
1051+
some previous type. For example, this might be used to represent local data, or
10521052
by a GraphQL service which is itself an extension of another GraphQL service.
10531053

10541054
In this example, a local data field is added to a `Story` type:
@@ -1076,10 +1076,10 @@ Object type extensions have the potential to be invalid if incorrectly defined.
10761076
2. The fields of an Object type extension must have unique names; no two fields
10771077
may share the same name.
10781078
3. Any fields of an Object type extension must not be already defined on the
1079-
original Object type.
1080-
4. Any non-repeatable directives provided must not already apply to the original
1079+
previous Object type.
1080+
4. Any non-repeatable directives provided must not already apply to the previous
10811081
Object type.
1082-
5. Any interfaces provided must not be already implemented by the original
1082+
5. Any interfaces provided must not be already implemented by the previous
10831083
Object type.
10841084
6. The resulting extended object type must be a super-set of all interfaces it
10851085
implements.
@@ -1288,7 +1288,7 @@ InterfaceTypeExtension :
12881288
- extend interface Name ImplementsInterfaces [lookahead != `{`]
12891289

12901290
Interface type extensions are used to represent an interface which has been
1291-
extended from some original interface. For example, this might be used to
1291+
extended from some previous interface. For example, this might be used to
12921292
represent common local data on many types, or by a GraphQL service which is
12931293
itself an extension of another GraphQL service.
12941294

@@ -1328,11 +1328,11 @@ defined.
13281328
2. The fields of an Interface type extension must have unique names; no two
13291329
fields may share the same name.
13301330
3. Any fields of an Interface type extension must not be already defined on the
1331-
original Interface type.
1332-
4. Any Object or Interface type which implemented the original Interface type
1331+
previous Interface type.
1332+
4. Any Object or Interface type which implemented the previous Interface type
13331333
must also be a super-set of the fields of the Interface type extension (which
13341334
may be due to Object type extension).
1335-
5. Any non-repeatable directives provided must not already apply to the original
1335+
5. Any non-repeatable directives provided must not already apply to the previous
13361336
Interface type.
13371337
6. The resulting extended Interface type must be a super-set of all Interfaces
13381338
it implements.
@@ -1443,7 +1443,7 @@ UnionTypeExtension :
14431443
- extend union Name Directives[Const]
14441444

14451445
Union type extensions are used to represent a union type which has been extended
1446-
from some original union type. For example, this might be used to represent
1446+
from some previous union type. For example, this might be used to represent
14471447
additional local data, or by a GraphQL service which is itself an extension of
14481448
another GraphQL service.
14491449

@@ -1457,8 +1457,8 @@ Union type extensions have the potential to be invalid if incorrectly defined.
14571457
Similarly, wrapping types must not be member types of a Union.
14581458
3. All member types of a Union type extension must be unique.
14591459
4. All member types of a Union type extension must not already be a member of
1460-
the original Union type.
1461-
5. Any non-repeatable directives provided must not already apply to the original
1460+
the previous Union type.
1461+
5. Any non-repeatable directives provided must not already apply to the previous
14621462
Union type.
14631463

14641464
## Enums
@@ -1520,7 +1520,7 @@ EnumTypeExtension :
15201520
- extend enum Name Directives[Const] [lookahead != `{`]
15211521

15221522
Enum type extensions are used to represent an enum type which has been extended
1523-
from some original enum type. For example, this might be used to represent
1523+
from some previous enum type. For example, this might be used to represent
15241524
additional local data, or by a GraphQL service which is itself an extension of
15251525
another GraphQL service.
15261526

@@ -1531,8 +1531,8 @@ Enum type extensions have the potential to be invalid if incorrectly defined.
15311531
1. The named type must already be defined and must be an Enum type.
15321532
2. All values of an Enum type extension must be unique.
15331533
3. All values of an Enum type extension must not already be a value of the
1534-
original Enum.
1535-
4. Any non-repeatable directives provided must not already apply to the original
1534+
previous Enum.
1535+
4. Any non-repeatable directives provided must not already apply to the previous
15361536
Enum type.
15371537

15381538
## Input Objects
@@ -1712,7 +1712,7 @@ InputObjectTypeExtension :
17121712
- extend input Name Directives[Const] [lookahead != `{`]
17131713

17141714
Input object type extensions are used to represent an input object type which
1715-
has been extended from some original input object type. For example, this might
1715+
has been extended from some previous input object type. For example, this might
17161716
be used by a GraphQL service which is itself an extension of another GraphQL
17171717
service.
17181718

@@ -1724,8 +1724,8 @@ defined.
17241724
1. The named type must already be defined and must be a Input Object type.
17251725
2. All fields of an Input Object type extension must have unique names.
17261726
3. All fields of an Input Object type extension must not already be a field of
1727-
the original Input Object.
1728-
4. Any non-repeatable directives provided must not already apply to the original
1727+
the previous Input Object.
1728+
4. Any non-repeatable directives provided must not already apply to the previous
17291729
Input Object type.
17301730

17311731
## List
@@ -1780,7 +1780,9 @@ Following are examples of input coercion with various list types and values:
17801780
| `[Int]` | `1` | `[1]` |
17811781
| `[Int]` | `null` | `null` |
17821782
| `[[Int]]` | `[[1], [2, 3]]` | `[[1], [2, 3]]` |
1783-
| `[[Int]]` | `[1, 2, 3]` | Error: Incorrect item value |
1783+
| `[[Int]]` | `[1, 2, 3]` | `[[1], [2], [3]]` |
1784+
| `[[Int]]` | `[1, null, 3]` | `[[1], null, [3]]` |
1785+
| `[[Int]]` | `[[1], ["b"]]` | Error: Incorrect item value |
17841786
| `[[Int]]` | `1` | `[[1]]` |
17851787
| `[[Int]]` | `null` | `null` |
17861788

@@ -2099,7 +2101,7 @@ condition is false.
20992101

21002102
```graphql
21012103
directive @deprecated(
2102-
reason: String = "No longer supported"
2104+
reason: String! = "No longer supported"
21032105
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE
21042106
```
21052107

spec/Section 4 -- Introspection.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ CommonMark-compliant Markdown renderer.
110110

111111
To support the management of backwards compatibility, GraphQL fields, arguments,
112112
input fields, and enum values can indicate whether or not they are deprecated
113-
(`isDeprecated: Boolean`) along with a description of why it is deprecated
113+
(`isDeprecated: Boolean!`) along with a description of why it is deprecated
114114
(`deprecationReason: String`).
115115

116116
Tools built using GraphQL introspection should respect deprecation by
@@ -424,7 +424,8 @@ Fields\:
424424
this field.
425425
- `isDeprecated` returns {true} if this field should no longer be used,
426426
otherwise {false}.
427-
- `deprecationReason` optionally provides a reason why this field is deprecated.
427+
- `deprecationReason` returns the reason why this field is deprecated, or null
428+
if this field is not deprecated.
428429

429430
### The \_\_InputValue Type
430431

@@ -442,8 +443,8 @@ Fields\:
442443
provided at runtime. If this input value has no default value, returns {null}.
443444
- `isDeprecated` returns {true} if this input field or argument should no longer
444445
be used, otherwise {false}.
445-
- `deprecationReason` optionally provides a reason why this input field or
446-
argument is deprecated.
446+
- `deprecationReason` returns the reason why this input field or argument is
447+
deprecated, or null if the input field or argument is not deprecated.
447448

448449
### The \_\_EnumValue Type
449450

@@ -455,8 +456,8 @@ Fields\:
455456
- `description` may return a String or {null}.
456457
- `isDeprecated` returns {true} if this enum value should no longer be used,
457458
otherwise {false}.
458-
- `deprecationReason` optionally provides a reason why this enum value is
459-
deprecated.
459+
- `deprecationReason` returns the reason why this enum value is deprecated, or
460+
null if the enum value is not deprecated.
460461

461462
### The \_\_Directive Type
462463

spec/Section 6 -- Execution.md

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ ExecuteMutation(mutation, schema, variableValues, initialValue):
157157

158158
### Subscription
159159

160-
If the operation is a subscription, the result is an event stream called the
160+
If the operation is a subscription, the result is an _event stream_ called the
161161
"Response Stream" where each event in the event stream is the result of
162162
executing the operation for each new event on an underlying "Source Stream".
163163

@@ -210,14 +210,21 @@ chat room ID is the "topic" and each "publish" contains the sender and text.
210210

211211
**Event Streams**
212212

213-
An event stream represents a sequence of discrete events over time which can be
214-
observed. As an example, a "Pub-Sub" system may produce an event stream when
215-
"subscribing to a topic", with an event occurring on that event stream for each
216-
"publish" to that topic. Event streams may produce an infinite sequence of
217-
events or may complete at any point. Event streams may complete in response to
218-
an error or simply because no more events will occur. An observer may at any
219-
point decide to stop observing an event stream by cancelling it, after which it
220-
must receive no more events from that event stream.
213+
:: An _event stream_ represents a sequence of events: discrete emitted values
214+
over time which can be observed. As an example, a "Pub-Sub" system may produce
215+
an _event stream_ when "subscribing to a topic", with an value emitted for each
216+
"publish" to that topic.
217+
218+
An _event stream_ may complete at any point, often because no further events
219+
will occur. An _event stream_ may emit an infinite sequence of values, in which
220+
it may never complete. If an _event stream_ encounters an error, it must
221+
complete with that error.
222+
223+
An observer may at any point decide to stop observing an _event stream_ by
224+
cancelling it. When an _event stream_ is cancelled, it must complete.
225+
226+
Internal user code also may cancel an _event stream_ for any reason, which would
227+
be observed as that _event stream_ completing.
221228

222229
**Supporting Subscriptions at Scale**
223230

@@ -243,8 +250,8 @@ service details should be chosen by the implementing service.
243250

244251
#### Source Stream
245252

246-
A Source Stream represents the sequence of events, each of which will trigger a
247-
GraphQL execution corresponding to that event. Like field value resolution, the
253+
A Source Stream is an _event stream_ representing a sequence of root values,
254+
each of which will trigger a GraphQL execution. Like field value resolution, the
248255
logic to create a Source Stream is application-specific.
249256

250257
CreateSourceEventStream(subscription, schema, variableValues, initialValue):
@@ -261,15 +268,15 @@ CreateSourceEventStream(subscription, schema, variableValues, initialValue):
261268
- Let {field} be the first entry in {fields}.
262269
- Let {argumentValues} be the result of {CoerceArgumentValues(subscriptionType,
263270
field, variableValues)}.
264-
- Let {fieldStream} be the result of running
271+
- Let {sourceStream} be the result of running
265272
{ResolveFieldEventStream(subscriptionType, initialValue, fieldName,
266273
argumentValues)}.
267-
- Return {fieldStream}.
274+
- Return {sourceStream}.
268275

269276
ResolveFieldEventStream(subscriptionType, rootValue, fieldName, argumentValues):
270277

271278
- Let {resolver} be the internal function provided by {subscriptionType} for
272-
determining the resolved event stream of a subscription field named
279+
determining the resolved _event stream_ of a subscription field named
273280
{fieldName}.
274281
- Return the result of calling {resolver}, providing {rootValue} and
275282
{argumentValues}.
@@ -280,17 +287,33 @@ operation type.
280287

281288
#### Response Stream
282289

283-
Each event in the underlying Source Stream triggers execution of the
284-
subscription _selection set_ using that event as a root value.
290+
Each event from the underlying Source Stream triggers execution of the
291+
subscription _selection set_ using that event's value as the {initialValue}.
285292

286293
MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
287294

288-
- Return a new event stream {responseStream} which yields events as follows:
289-
- For each {event} on {sourceStream}:
290-
- Let {response} be the result of running
291-
{ExecuteSubscriptionEvent(subscription, schema, variableValues, event)}.
292-
- Yield an event containing {response}.
293-
- When {sourceStream} completes: complete {responseStream}.
295+
- Let {responseStream} be a new _event stream_.
296+
- When {sourceStream} emits {sourceValue}:
297+
- Let {response} be the result of running
298+
{ExecuteSubscriptionEvent(subscription, schema, variableValues,
299+
sourceValue)}.
300+
- If internal {error} was raised:
301+
- Cancel {sourceStream}.
302+
- Complete {responseStream} with {error}.
303+
- Otherwise emit {response} on {responseStream}.
304+
- When {sourceStream} completes normally:
305+
- Complete {responseStream} normally.
306+
- When {sourceStream} completes with {error}:
307+
- Complete {responseStream} with {error}.
308+
- When {responseStream} is cancelled:
309+
- Cancel {sourceStream}.
310+
- Complete {responseStream} normally.
311+
- Return {responseStream}.
312+
313+
Note: Since {ExecuteSubscriptionEvent()} handles all _field error_, and _request
314+
error_ only occur during {CreateSourceEventStream()}, the only remaining error
315+
condition handled from {ExecuteSubscriptionEvent()} are internal exceptional
316+
errors not described by this specification.
294317

295318
ExecuteSubscriptionEvent(subscription, schema, variableValues, initialValue):
296319

@@ -306,9 +329,9 @@ Note: The {ExecuteSubscriptionEvent()} algorithm is intentionally similar to
306329
#### Unsubscribe
307330

308331
Unsubscribe cancels the Response Stream when a client no longer wishes to
309-
receive payloads for a subscription. This may in turn also cancel the Source
310-
Stream. This is also a good opportunity to clean up any other resources used by
311-
the subscription.
332+
receive payloads for a subscription. This in turn also cancels the Source
333+
Stream, which is a good opportunity to clean up any other resources used by the
334+
subscription.
312335

313336
Unsubscribe(responseStream):
314337

@@ -679,7 +702,8 @@ ResolveFieldValue(objectType, objectValue, fieldName, argumentValues):
679702
Note: It is common for {resolver} to be asynchronous due to relying on reading
680703
an underlying database or networked service to produce a value. This
681704
necessitates the rest of a GraphQL executor to handle an asynchronous execution
682-
flow.
705+
flow. If the field is of a list type, each value in the collection of values
706+
returned by {resolver} may itself be retrieved asynchronously.
683707

684708
### Value Completion
685709

spec/Section 7 -- Response.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ of the query root operation type; if the operation was a mutation, this output
4343
will be an object of the mutation root operation type.
4444

4545
If an error was raised before execution begins, the `data` entry should not be
46-
present in the result.
46+
present in the response.
4747

4848
If an error was raised during the execution that prevented a valid response, the
4949
`data` entry in the response should be `null`.
@@ -56,7 +56,7 @@ format below.
5656

5757
If present, the `errors` entry in the response must contain at least one error.
5858
If no errors were raised during the request, the `errors` entry must not be
59-
present in the result.
59+
present in the response.
6060

6161
If the `data` entry in the response is not present, the `errors` entry must be
6262
present. It must contain at least one _request error_ indicating why no data was

0 commit comments

Comments
 (0)