@@ -8,11 +8,11 @@ request.
88A response may contain both a partial response as well as encountered errors in
99the case that a field error occurred on a field which was replaced with {null}.
1010
11+ A response to a GraphQL operation must be a map or an event stream of maps. The
12+ value of this map is described in the "Response Format" section.
1113
1214## Response Format
1315
14- A response to a GraphQL operation must be a map.
15-
1616If the operation encountered any errors, the response map must contain an
1717entry with key ` errors ` . The value of this entry is described in the "Errors"
1818section. If the operation completed without encountering any errors, this entry
@@ -23,11 +23,24 @@ with key `data`. The value of this entry is described in the "Data" section. If
2323the operation failed before execution, due to a syntax error, missing
2424information, or validation error, this entry must not be present.
2525
26+ If the response of the GraphQL operation is an event stream, each response map
27+ must contain an entry with key ` hasNext ` . The value of this entry is ` true ` for
28+ all but the last response in the stream. The value of this entry is ` false ` for
29+ the last response of the stream. This entry is not required for GraphQL
30+ operations that return a single response map.
31+
2632The response map may also contain an entry with key ` extensions ` . This entry,
2733if set, must have a map as its value. This entry is reserved for implementors
2834to extend the protocol however they see fit, and hence there are no additional
2935restrictions on its contents.
3036
37+ When the response of the GraphQL operation is an event stream, the first value
38+ will be the initial response. All subsequent values must contain ` label ` and
39+ ` path ` entries. These two entries are used by clients to identify the the
40+ ` @defer ` or ` @stream ` directive from the GraphQL operation that triggered this
41+ value to be returned by the event stream. The combination of these two entries
42+ must be unique across all values returned by the event stream.
43+
3144To ensure future changes to the protocol do not break existing servers and
3245clients, the top level response map must not contain any entries other than the
3346three described above.
@@ -43,6 +56,11 @@ requested operation. If the operation was a query, this output will be an
4356object of the schema's query root type; if the operation was a mutation, this
4457output will be an object of the schema's mutation root type.
4558
59+ If the result of the operation is an event stream, the ` data ` entry in
60+ subsequent values will be an object of the type of a particular field in the
61+ GraphQL result. The adjacent ` path ` field will contain the path segments of
62+ the field this data is associated with.
63+
4664If an error was encountered before execution begins, the ` data ` entry should
4765not be present in the result.
4866
@@ -82,14 +100,8 @@ associated syntax element.
82100If an error can be associated to a particular field in the GraphQL result, it
83101must contain an entry with the key ` path ` that details the path of the
84102response field which experienced the error. This allows clients to identify
85- whether a ` null ` result is intentional or caused by a runtime error.
86-
87- This field should be a list of path segments starting at the root of the
88- response and ending with the field associated with the error. Path segments
89- that represent fields should be strings, and path segments that
90- represent list indices should be 0-indexed integers. If the error happens
91- in an aliased field, the path to the error should use the aliased name, since
92- it represents a path in the response, not in the query.
103+ whether a ` null ` result is intentional or caused by a runtime error. The value
104+ of this field is described in the "Path" section.
93105
94106For example, if fetching one of the friends' names fails in the following
95107query:
@@ -220,6 +232,29 @@ still discouraged.
220232```
221233
222234
235+ ## Path
236+
237+ A ` path ` field allows for the association to a particular field in a GraphQL
238+ result. This field should be a list of path segments starting at the root of the
239+ response and ending with the field to be associated with. Path segments
240+ that represent fields should be strings, and path segments that
241+ represent list indices should be 0-indexed integers. If the path is associated to
242+ an aliased field, the path should use the aliased name, since it represents a path in the response, not in the query.
243+
244+ When the ` path ` field is present on a GraphQL response, it indicates that the
245+ ` data ` field is not the root query or mutation result, but is rather associated to
246+ a particular field in the root result.
247+
248+ When the ` path ` field is present on an "Error result", it indicates the response field which experienced the error.
249+
250+ ## Label
251+
252+ If the response of the GraphQL operation is an event stream, subsequent values
253+ will contain a string field ` label ` . This ` label ` is the same label passed to
254+ the ` @defer ` or ` @stream ` directive that triggered this value. This allows
255+ clients to identify which ` @defer ` or ` @stream ` directive is associated with
256+ this value.
257+
223258## Serialization Format
224259
225260GraphQL does not require a specific serialization format. However, clients
0 commit comments