@@ -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
2024If the request raised any errors, the response map must contain an entry with
2125key ` errors ` . The value of this entry is described in the "Errors" section. If
2226the request completed without raising any errors, this entry must not be
2327present.
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
5249To 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
5451entries 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
5855response 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
6283The ` data ` entry in the response will be the result of the execution of the
@@ -70,9 +91,9 @@ present in the result.
7091If 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
282303The ` 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
287308Each Pending Result corresponds to either a ` @defer ` or ` @stream ` directive
288309located at a specific path in the response data. The Pending Result is used to
289310communicate that the GraphQL service has chosen to incrementally deliver the
290311data 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
296317Every Pending Result must contain an entry with the key ` id ` with a string
297318value. This ` id ` should be used by clients to correlate Pending Results with
298319Completed 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
302323Every Pending Result must contain an entry with the key ` path ` . When the Pending
303324Result is associated with a ` @stream ` directive, it indicates the response list
@@ -315,15 +336,14 @@ argument.
315336If a Pending Result is not returned for a ` @defer ` or ` @stream ` directive,
316337clients must assume that the GraphQL service chose not to incrementally deliver
317338this 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
322343The ` 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
328348The Incremental Result is used to deliver data that the GraphQL service has
329349chosen to incrementally deliver. An Incremental Result may be ether an
@@ -410,14 +430,14 @@ the "Errors" section.
410430### Completed
411431
412432The ` 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
417437Each Completed Result corresponds to a prior Pending Result. The Completed
418438Result is used to communicate that the GraphQL service has completed the
419439incremental 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