Skip to content

Commit d5866f7

Browse files
committed
Merge branch 'main' into values-of-correct-type-variables
2 parents 7d86799 + 5bf400e commit d5866f7

File tree

5 files changed

+63
-37
lines changed

5 files changed

+63
-37
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ ExecuteMutation(mutation, schema, variableValues, initialValue):
164164

165165
### Subscription
166166

167-
If the operation is a subscription, the result is an event stream called the
167+
If the operation is a subscription, the result is an _event stream_ called the
168168
"Response Stream" where each event in the event stream is the result of
169169
executing the operation for each new event on an underlying "Source Stream".
170170

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

218218
**Event Streams**
219219

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

229236
**Supporting Subscriptions at Scale**
230237

@@ -250,8 +257,8 @@ service details should be chosen by the implementing service.
250257

251258
#### Source Stream
252259

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

257264
CreateSourceEventStream(subscription, schema, variableValues, initialValue):
@@ -268,15 +275,15 @@ CreateSourceEventStream(subscription, schema, variableValues, initialValue):
268275
- Let {field} be the first entry in {fields}.
269276
- Let {argumentValues} be the result of {CoerceArgumentValues(subscriptionType,
270277
field, variableValues)}.
271-
- Let {fieldStream} be the result of running
278+
- Let {sourceStream} be the result of running
272279
{ResolveFieldEventStream(subscriptionType, initialValue, fieldName,
273280
argumentValues)}.
274-
- Return {fieldStream}.
281+
- Return {sourceStream}.
275282

276283
ResolveFieldEventStream(subscriptionType, rootValue, fieldName, argumentValues):
277284

278285
- Let {resolver} be the internal function provided by {subscriptionType} for
279-
determining the resolved event stream of a subscription field named
286+
determining the resolved _event stream_ of a subscription field named
280287
{fieldName}.
281288
- Return the result of calling {resolver}, providing {rootValue} and
282289
{argumentValues}.
@@ -287,17 +294,33 @@ operation type.
287294

288295
#### Response Stream
289296

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

293300
MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
294301

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

302325
ExecuteSubscriptionEvent(subscription, schema, variableValues, initialValue):
303326

@@ -317,9 +340,9 @@ Note: The {ExecuteSubscriptionEvent()} algorithm is intentionally similar to
317340
#### Unsubscribe
318341

319342
Unsubscribe cancels the Response Stream when a client no longer wishes to
320-
receive payloads for a subscription. This may in turn also cancel the Source
321-
Stream. This is also a good opportunity to clean up any other resources used by
322-
the subscription.
343+
receive payloads for a subscription. This in turn also cancels the Source
344+
Stream, which is a good opportunity to clean up any other resources used by the
345+
subscription.
323346

324347
Unsubscribe(responseStream):
325348

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)