Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aa9c21c

Browse files
committedJan 3, 2025·
payload -> response
1 parent 03adfb9 commit aa9c21c

File tree

3 files changed

+112
-92
lines changed

3 files changed

+112
-92
lines changed
 

Diff for: ‎spec/Appendix C -- Examples.md

+29-29
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ fragment HomeWorldFragment on Person {
2121
}
2222
```
2323

24-
The response stream might look like:
24+
The incremental stream might look like:
2525

26-
Payload 1, the initial response does not contain any deferred or streamed
27-
results in the `data` entry. The initial response contains a `hasNext` entry,
28-
indicating that subsequent payloads will be delivered. There are two Pending
29-
Responses indicating that results for both the `@defer` and `@stream` in the
30-
query will be delivered in the subsequent payloads.
26+
The initial response does not contain any deferred or streamed results in the
27+
`data` entry. The initial response contains a `hasNext` entry, indicating that
28+
subsequent responses will be delivered. There are two Pending Responses
29+
indicating that results for both the `@defer` and `@stream` in the query will be
30+
delivered in the subsequent responses.
3131

3232
```json example
3333
{
@@ -45,9 +45,9 @@ query will be delivered in the subsequent payloads.
4545
}
4646
```
4747

48-
Payload 2, contains the deferred data and the first streamed list item. There is
49-
one Completed Result, indicating that the deferred data has been completely
50-
delivered.
48+
Subsequent response 1, contains the deferred data and the first streamed list
49+
item. There is one Completed Result, indicating that the deferred data has been
50+
completely delivered.
5151

5252
```json example
5353
{
@@ -68,10 +68,10 @@ delivered.
6868
}
6969
```
7070

71-
Payload 3, contains the final stream payload. In this example, the underlying
72-
iterator does not close synchronously so {hasNext} is set to {true}. If this
73-
iterator did close synchronously, {hasNext} would be set to {false} and this
74-
would be the final response.
71+
Subsequent response 2, contains the final stream results. In this example, the
72+
underlying iterator does not close synchronously so {hasNext} is set to {true}.
73+
If this iterator did close synchronously, {hasNext} would be set to {false} and
74+
this would be the final response.
7575

7676
```json example
7777
{
@@ -85,9 +85,9 @@ would be the final response.
8585
}
8686
```
8787

88-
Payload 4, contains no incremental data. {hasNext} set to {false} indicates the
89-
end of the response stream. This response is sent when the underlying iterator
90-
of the `films` field closes.
88+
Subsequent response 3, contains no incremental data. {hasNext} set to {false}
89+
indicates the end of the incremental stream. This response is sent when the
90+
underlying iterator of the `films` field closes.
9191

9292
```json example
9393
{
@@ -121,14 +121,14 @@ fragment NameAndHomeWorldFragment on Person {
121121
}
122122
```
123123

124-
The response stream might look like:
124+
The incremental stream might look like:
125125

126-
Payload 1, the initial response contains the results of the `firstName` field.
127-
Even though it is also present in the `HomeWorldFragment`, it must be returned
128-
in the initial payload because it is also defined outside of any fragments with
129-
the `@defer` directive. Additionally, There are two Pending Responses indicating
126+
The initial response contains the results of the `firstName` field. Even though
127+
it is also present in the `HomeWorldFragment`, it must be returned in the
128+
initial response because it is also defined outside of any fragments with the
129+
`@defer` directive. Additionally, There are two Pending Responses indicating
130130
that results for both `@defer`s in the query will be delivered in the subsequent
131-
payloads.
131+
responses.
132132

133133
```json example
134134
{
@@ -145,10 +145,10 @@ payloads.
145145
}
146146
```
147147

148-
Payload 2, contains the deferred data from `HomeWorldFragment`. There is one
149-
Completed Result, indicating that `HomeWorldFragment` has been completely
150-
delivered. Because the `homeWorld` field is present in two separate `@defer`s,
151-
it is separated into its own Incremental Result.
148+
Subsequent response 1, contains the deferred data from `HomeWorldFragment`.
149+
There is one Completed Result, indicating that `HomeWorldFragment` has been
150+
completely delivered. Because the `homeWorld` field is present in two separate
151+
`@defer`s, it is separated into its own Incremental Result.
152152

153153
The second Incremental Result contains the data for the `terrain` field. This
154154
incremental result contains a `subPath` property to indicate to clients that the
@@ -173,9 +173,9 @@ Result with id `"0"` and this `subPath` entry.
173173
}
174174
```
175175

176-
Payload 3, contains the remaining data from the `NameAndHomeWorldFragment`.
177-
`lastName` is the only remaining field that has not been delivered in a previous
178-
payload.
176+
Subsequent response 2, contains the remaining data from the
177+
`NameAndHomeWorldFragment`. `lastName` is the only remaining field that has not
178+
been delivered in a previous response.
179179

180180
```json example
181181
{

Diff for: ‎spec/Section 3 -- Type System.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -2182,9 +2182,9 @@ directive @defer(
21822182

21832183
The `@defer` directive may be provided on a fragment spread or inline fragment
21842184
to indicate that execution of the related selection set should be deferred. When
2185-
a request includes the `@defer` directive, the response may consist of multiple
2186-
payloads: the initial payload containing all non-deferred data, while subsequent
2187-
payloads include deferred data.
2185+
a request includes the `@defer` directive, the result may consist of multiple
2186+
responses: the initial response containing all non-deferred data, while
2187+
subsequent responses include deferred data.
21882188

21892189
The `@include` and `@skip` directives take precedence over `@defer`.
21902190

@@ -2209,7 +2209,7 @@ fragment someFragment on User {
22092209
related note below). When `false`, fragment will not be deferred. Defaults to
22102210
`true` when omitted.
22112211
- `label: String` - An optional string literal (variables are disallowed) used
2212-
by GraphQL clients to identify data from payloads and associate it with the
2212+
by GraphQL clients to identify data from responses and associate it with the
22132213
corresponding defer directive. If provided, the GraphQL service must include
22142214
this label in the corresponding pending object within the response. The
22152215
`label` argument must be unique across all `@defer` and `@stream` directives
@@ -2228,7 +2228,7 @@ directive @stream(
22282228
The `@stream` directive may be provided for a field whose type incorporates a
22292229
`List` type modifier; the directive enables the backend to leverage technology
22302230
such as asynchronous iterators to provide a partial list initially, and
2231-
additional list items in subsequent payloads.
2231+
additional list items in subsequent responses.
22322232

22332233
The `@include` and `@skip` directives take precedence over `@stream`.
22342234

@@ -2255,11 +2255,11 @@ query myQuery($shouldStream: Boolean! = true) {
22552255
note below). When `false`, the field will not be streamed and all list items
22562256
will be initially included. Defaults to `true` when omitted.
22572257
- `label: String` - An optional string literal (variables are disallowed) used
2258-
by GraphQL clients to identify data from payloads and associate it with the
2258+
by GraphQL clients to identify data from responses and associate it with the
22592259
corresponding stream directive. If provided, the GraphQL service must include
2260-
this label in the corresponding pending object within the response. The
2261-
`label` argument must be unique across all `@defer` and `@stream` directives
2262-
in the document.
2260+
this label in the corresponding pending object within the result. The `label`
2261+
argument must be unique across all `@defer` and `@stream` directives in the
2262+
document.
22632263
- `initialCount: Int` - The number of list items the service should return
22642264
initially. If omitted, defaults to `0`. A field error will be raised if the
22652265
value of this argument is less than `0`.

Diff for: ‎spec/Section 7 -- Response.md

+74-54
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,74 @@ the case that any _field error_ was raised on a field and was replaced with
1010

1111
## Response Format
1212

13-
A response to a GraphQL request must be a map or a stream of incrementally
14-
delivered payloads. The response will be a stream of incrementally delivered
15-
payloads when the GraphQL service has deferred or streamed data as a result of
16-
the `@defer` or `@stream` directives. When the response of the GraphQL operation
17-
contains incrementally delivered payloads, the first value will be an initial
18-
payload, followed by one or more subsequent payloads.
13+
The result of a GraphQL request must be either a single initial response or an
14+
incremental stream. The response will be an incremental stream when the GraphQL
15+
service has deferred or streamed data as a result of the `@defer` or `@stream`
16+
directives. When the result of the GraphQL operation is an incremental stream,
17+
the first value will be an initial response, followed by one or more subsequent
18+
responses.
19+
20+
### Initial Response
21+
22+
An initial response must be a map.
1923

2024
If the request raised any errors, the response map must contain an entry with
2125
key `errors`. The value of this entry is described in the "Errors" section. If
2226
the request completed without raising any errors, this entry must not be
2327
present.
2428

25-
If the request included execution, the response map must contain an entry with
26-
key `data`. The value of this entry is described in the "Data" section. If the
27-
request failed before execution, due to a syntax error, missing information, or
28-
validation error, this entry must not be present.
29-
30-
When the response of the GraphQL operation contains incrementally delivered
31-
payloads, both the initial payload and all subsequent payloads must contain an
32-
entry with key `hasNext`. The value of this entry must be {true} for all but the
33-
last response in the stream. The value of this entry must be {false} for the
34-
last response of the stream. This entry must not be present for GraphQL
35-
operations that return a single response map.
36-
37-
When the response of the GraphQL operation contains incrementally delivered
38-
payloads, both the initial payload and any subsequent payloads may contain
39-
entries with the keys `pending`, `incremental`, and/or `completed`. The value of
40-
these entries are described in the "Pending", "Incremental", and "Completed"
41-
sections below.
42-
43-
The response map may also contain an entry with key `extensions`. This entry, if
44-
set, must have a map as its value. This entry is reserved for implementers to
45-
extend the protocol however they see fit, and hence there are no additional
46-
restrictions on its contents. When the response of the GraphQL operation is a
47-
response stream, the initial payload and any subsequent payloads may contain an
48-
entry with the key `extensions`, also reserved for implementers to extend the
49-
protocol however they see fit. Additionally, implementers may send subsequent
50-
payloads containing only `hasNext` and `extensions` entries.
29+
If the request included execution, the initial response map must contain an
30+
entry with key `data`. The value of this entry is described in the "Data"
31+
section. If the request failed before execution, due to a syntax error, missing
32+
information, or validation error, this entry must not be present.
33+
34+
When the result of the GraphQL operation is an incremental stream, the initial
35+
response must contain an entry with key `hasNext`. The value of this entry must
36+
be {true}. This entry must not be present for GraphQL operations that result in
37+
a single initial response.
38+
39+
When the result of the GraphQL operation is an incremental stream, the initial
40+
response may contain entries with the keys `pending`, `incremental`, and/or
41+
`completed`. The value of these entries are described in the "Pending",
42+
"Incremental", and "Completed" sections below.
43+
44+
The initial response map may also contain an entry with key `extensions`. This
45+
entry, if set, must have a map as its value. This entry is reserved for
46+
implementers to extend the protocol however they see fit, and hence there are no
47+
additional restrictions on its contents.
5148

5249
To ensure future changes to the protocol do not break existing services and
53-
clients, the top level response map must not contain any entries other than the
50+
clients, the initial response map must not contain any entries other than the
5451
entries described above.
5552

56-
Note: When `errors` is present in the response, it may be helpful for it to
57-
appear first when serialized to make it more clear when errors are present in a
53+
Note: When `errors` is present in a response, it may be helpful for it to appear
54+
first when serialized to make it more clear when errors are present in a
5855
response during debugging.
5956

57+
### Subsequent Response
58+
59+
When the result of the GraphQL operation is an incremental stream, the first
60+
value will be an initial response, followed by one or more subsequent responses.
61+
A subsequent response must be a map.
62+
63+
Each subsequent response must contain an entry with key `hasNext`. The value of
64+
this entry must be {true} for all but the last response in the stream. The value
65+
of this entry must be {false} for the last response of the stream.
66+
67+
Each subsequent response may contain entries with the keys `pending`,
68+
`incremental`, and/or `completed`. The value of these entries are described in
69+
the "Pending", "Incremental", and "Completed" sections below.
70+
71+
The subsequent response map may also contain an entry with key `extensions`.
72+
This entry, if set, must have a map as its value. This entry is reserved for
73+
implementers to extend the protocol however they see fit, and hence there are no
74+
additional restrictions on its contents. Implementers may send subsequent
75+
responses containing only `hasNext` and `extensions` entries.
76+
77+
To ensure future changes to the protocol do not break existing services and
78+
clients, the initial response map must not contain any entries other than the
79+
entries described above.
80+
6081
### Data
6182

6283
The `data` entry in the response will be the result of the execution of the
@@ -70,9 +91,9 @@ present in the result.
7091
If an error was raised during the execution that prevented a valid response, the
7192
`data` entry in the response should be `null`.
7293

73-
When the response of the GraphQL operation contains incrementally delivered
74-
payloads, `data` may only be present in the initial payload. `data` must not be
75-
present in any subsequent payloads.
94+
When the response of the GraphQL operation is an incremental stream, `data` may
95+
only be present in the initial response. `data` must not be present in any
96+
subsequent responses.
7697

7798
### Errors
7899

@@ -280,24 +301,24 @@ field which experienced the error.
280301
### Pending
281302

282303
The `pending` entry in the response is a non-empty list of Pending Results. If
283-
the response of the GraphQL operation contains incrementally delivered payloads,
284-
this field may appear on both the initial and subsequent payloads. If present,
285-
the `pending` entry must contain at least one Pending Result.
304+
the response of the GraphQL operation is an incremental stream, this field may
305+
appear on both the initial and subsequent responses. If present, the `pending`
306+
entry must contain at least one Pending Result.
286307

287308
Each Pending Result corresponds to either a `@defer` or `@stream` directive
288309
located at a specific path in the response data. The Pending Result is used to
289310
communicate that the GraphQL service has chosen to incrementally deliver the
290311
data associated with this `@defer` or `@stream` directive and clients should
291-
expect the associated data in either the current payload, or one of the
292-
following payloads.
312+
expect the associated data in either the current response, or one of the
313+
following responses.
293314

294315
**Pending Result Format**
295316

296317
Every Pending Result must contain an entry with the key `id` with a string
297318
value. This `id` should be used by clients to correlate Pending Results with
298319
Completed Results. The `id` value must be unique for the entire response stream.
299-
There must not be any other Pending Result in any payload that contains the same
300-
`id`.
320+
There must not be any other Pending Result in any response that contains the
321+
same `id`.
301322

302323
Every Pending Result must contain an entry with the key `path`. When the Pending
303324
Result is associated with a `@stream` directive, it indicates the response list
@@ -315,15 +336,14 @@ argument.
315336
If a Pending Result is not returned for a `@defer` or `@stream` directive,
316337
clients must assume that the GraphQL service chose not to incrementally deliver
317338
this data, and the data can be found either in the `data` entry in the initial
318-
payload, or one of the Incremental Results in a prior payload.
339+
response, or one of the Incremental Results in a prior subsequent response.
319340

320341
### Incremental
321342

322343
The `incremental` entry in the response is a non-empty list of Incremental
323-
Results. If the response of the GraphQL operation contains incrementally
324-
delivered payloads, this field may appear on both the initial and subsequent
325-
values. If present, the `incremental` entry must contain at least one
326-
Incremental Result.
344+
Results. If the response of the GraphQL operation is an incremental stream, this
345+
field may appear on both the initial and subsequent responses. If present, the
346+
`incremental` entry must contain at least one Incremental Result.
327347

328348
The Incremental Result is used to deliver data that the GraphQL service has
329349
chosen to incrementally deliver. An Incremental Result may be ether an
@@ -410,14 +430,14 @@ the "Errors" section.
410430
### Completed
411431

412432
The `completed` entry in the response is a non-empty list of Completed Results.
413-
If the response of the GraphQL operation contains incrementally delivered
414-
results, this field may appear on both the initial and subsequent payloads. If
415-
present, the `completed` entry must contain at least one Completed Result.
433+
If the response of the GraphQL operation is an incremental stream, this field
434+
may appear on both the initial and subsequent responses. If present, the
435+
`completed` entry must contain at least one Completed Result.
416436

417437
Each Completed Result corresponds to a prior Pending Result. The Completed
418438
Result is used to communicate that the GraphQL service has completed the
419439
incremental delivery of the data associated with the corresponding Pending
420-
Result. The associated data must have been completed in the current payload.
440+
Result. The associated data must have been completed in the current response.
421441

422442
**Completed Result Format**
423443

0 commit comments

Comments
 (0)
Please sign in to comment.