@@ -10,53 +10,74 @@ the case that any _field error_ was raised on a field and was replaced with
10
10
11
11
## Response Format
12
12
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.
19
23
20
24
If the request raised any errors, the response map must contain an entry with
21
25
key ` errors ` . The value of this entry is described in the "Errors" section. If
22
26
the request completed without raising any errors, this entry must not be
23
27
present.
24
28
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.
51
48
52
49
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
54
51
entries described above.
55
52
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
58
55
response during debugging.
59
56
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
+
60
81
### Data
61
82
62
83
The ` data ` entry in the response will be the result of the execution of the
@@ -70,9 +91,9 @@ present in the result.
70
91
If an error was raised during the execution that prevented a valid response, the
71
92
` data ` entry in the response should be ` null ` .
72
93
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 .
76
97
77
98
### Errors
78
99
@@ -280,24 +301,24 @@ field which experienced the error.
280
301
### Pending
281
302
282
303
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.
286
307
287
308
Each Pending Result corresponds to either a ` @defer ` or ` @stream ` directive
288
309
located at a specific path in the response data. The Pending Result is used to
289
310
communicate that the GraphQL service has chosen to incrementally deliver the
290
311
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 .
293
314
294
315
** Pending Result Format**
295
316
296
317
Every Pending Result must contain an entry with the key ` id ` with a string
297
318
value. This ` id ` should be used by clients to correlate Pending Results with
298
319
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 ` .
301
322
302
323
Every Pending Result must contain an entry with the key ` path ` . When the Pending
303
324
Result is associated with a ` @stream ` directive, it indicates the response list
@@ -315,15 +336,14 @@ argument.
315
336
If a Pending Result is not returned for a ` @defer ` or ` @stream ` directive,
316
337
clients must assume that the GraphQL service chose not to incrementally deliver
317
338
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 .
319
340
320
341
### Incremental
321
342
322
343
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.
327
347
328
348
The Incremental Result is used to deliver data that the GraphQL service has
329
349
chosen to incrementally deliver. An Incremental Result may be ether an
@@ -410,14 +430,14 @@ the "Errors" section.
410
430
### Completed
411
431
412
432
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.
416
436
417
437
Each Completed Result corresponds to a prior Pending Result. The Completed
418
438
Result is used to communicate that the GraphQL service has completed the
419
439
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 .
421
441
422
442
** Completed Result Format**
423
443
0 commit comments