@@ -17,12 +17,12 @@ A GraphQL request returns either a _response_ or a _response stream_.
1717or mutation. A _ response_ must be a map.
1818
1919If the request raised any errors, the response map must contain an entry with
20- key ` errors ` . The value of this entry is described in the "Errors" section. If
20+ key {" errors" . The value of this entry is described in the "Errors" section. If
2121the request completed without raising any errors, this entry must not be
2222present.
2323
2424If the request included execution, the response map must contain an entry with
25- key ` data ` . The value of this entry is described in the "Data" section. If the
25+ key {" data"} . The value of this entry is described in the "Data" section. If the
2626request failed before execution, due to a syntax error, missing information, or
2727validation error, this entry must not be present.
2828
@@ -35,7 +35,7 @@ To ensure future changes to the protocol do not break existing services and
3535clients, the top level response map must not contain any entries other than the
3636three described above.
3737
38- Note: When ` errors ` is present in the response, it may be helpful for it to
38+ Note: When {" errors"} is present in the response, it may be helpful for it to
3939appear first when serialized to make it more clear when errors are present in a
4040response during debugging.
4141
@@ -44,30 +44,29 @@ response during debugging.
4444:: A GraphQL request returns a _ response stream_ when the GraphQL operation is a
4545subscription. A _ response stream_ must be a stream of _ response_ .
4646
47- ### Data
48-
49- The ` data ` entry in the response will be the result of the execution of the
50- requested operation. If the operation was a query, this output will be an object
51- of the query root operation type; if the operation was a mutation, this output
52- will be an object of the mutation root operation type.
53-
54- If an error was raised before execution begins, the ` data ` entry should not be
55- present in the response.
47+ ### Response Position
5648
57- If an error was raised during the execution that prevented a valid response, the
58- ` data ` entry in the response should be ` null ` .
59-
60- ** Response Position**
49+ <a name =" sec-Path " >
50+ <!-- Legacy link, this section was previously titled "Path" -->
51+ </a >
6152
6253:: A _ response position_ is a uniquely identifiable position in the response
6354data produced during execution. It is either a direct entry in the {resultMap}
6455of a {ExecuteSelectionSet()}, or it is a position in a (potentially nested) List
65- value.
56+ value. Each response position is uniquely identifiable via a _ response path_ .
57+
58+ :: A _ response path_ uniquely identifies a _ response position_ via a list of
59+ path segments (response keys or list indicies) starting at the root of the
60+ response and ending with the associated response position.
6661
67- The response data is the result of accumulating the result of all response
68- positions during execution.
62+ The value for a _ response path_ must be a list of path segments. Path segments
63+ that represent field response keys must be strings, and path segments that
64+ represent list indices must be 0-indexed integers. If a path segment is
65+ associated with an aliased field it must use the aliased name, since it
66+ represents a path in the response, not in the request.
6967
70- Each _ response position_ is uniquely identifiable via a _ path entry_ .
68+ When a _ response path_ is present on an _ error result_ , it identifies the
69+ _ response position_ which raised the error.
7170
7271A single field execution may result in multiple response positions. For example,
7372
@@ -87,22 +86,38 @@ The hero's name would be found in the _response position_ identified by
8786` ["hero", "friends"] ` , the hero's first friend at ` ["hero", "friends", 0] ` and
8887that friend's name at ` ["hero", "friends", 0, "name"] ` .
8988
89+ ### Data
90+
91+ The {"data"} entry in the response will be the result of the execution of the
92+ requested operation. If the operation was a query, this output will be an object
93+ of the query root operation type; if the operation was a mutation, this output
94+ will be an object of the mutation root operation type.
95+
96+ The response data is the result of accumulating the resolved result of all
97+ response positions during execution.
98+
99+ If an error was raised before execution begins, the {"data"} entry should not be
100+ present in the response.
101+
102+ If an error was raised during the execution that prevented a valid response, the
103+ {"data"} entry in the response should be ` null ` .
104+
90105### Errors
91106
92- The ` errors ` entry in the response is a non-empty list of errors raised during
107+ The {" errors"} entry in the response is a non-empty list of errors raised during
93108the _ request_ , where each error is a map of data described by the error result
94109format below.
95110
96- If present, the ` errors ` entry in the response must contain at least one error.
97- If no errors were raised during the request, the ` errors ` entry must not be
98- present in the response.
111+ If present, the {" errors"} entry in the response must contain at least one
112+ error. If no errors were raised during the request, the {" errors"} entry must
113+ not be present in the response.
99114
100- If the ` data ` entry in the response is not present, the ` errors ` entry must be
101- present. It must contain at least one _ request error_ indicating why no data was
102- able to be returned.
115+ If the {" data"} entry in the response is not present, the {" errors"} entry must
116+ be present. It must contain at least one _ request error_ indicating why no data
117+ was able to be returned.
103118
104- If the ` data ` entry in the response is present (including if it is the value
105- {null}), the ` errors ` entry must be present if and only if one or more
119+ If the {" data"} entry in the response is present (including if it is the value
120+ {null}), the {" errors"} entry must be present if and only if one or more
106121_ execution error_ was raised during execution.
107122
108123** Request Errors**
@@ -114,9 +129,9 @@ to determine which operation to execute, or invalid input values for variables.
114129
115130A request error is typically the fault of the requesting client.
116131
117- If a request error is raised, the ` data ` entry in the response must not be
118- present, the ` errors ` entry must include the error, and request execution should
119- be halted.
132+ If a request error is raised, the {" data"} entry in the response must not be
133+ present, the {" errors"} entry must include the error, and request execution
134+ should be halted.
120135
121136** Execution Errors**
122137
@@ -136,31 +151,32 @@ An execution error is typically the fault of a GraphQL service.
136151
137152An _ execution error_ must occur at a specific _ response position_ , and may occur
138153in any response position. The response position of an execution error is
139- indicated via the error's ` path ` _ path entry _ .
154+ indicated via a _ response path _ in the error response 's {" path"} entry .
140155
141156When an execution error is raised at a given _ response position_ , then that
142- response position must not be present within the _ response_ ` data ` entry (except
143- {null}), and the ` errors ` entry must include the error. Nested execution is
144- halted and sibling execution attempts to continue, producing partial result (see
157+ response position must not be present within the _ response_ {"data"} entry
158+ (except {null}), and the {"errors"} entry must include the error. Nested
159+ execution is halted and sibling execution attempts to continue, producing
160+ partial result (see
145161[ Handling Execution Errors] ( #sec-Handling-Execution-Errors ) ).
146162
147163** Error Result Format**
148164
149- Every error must contain an entry with the key ` message ` with a string
165+ Every error must contain an entry with the key {" message"} with a string
150166description of the error intended for the developer as a guide to understand and
151167correct the error.
152168
153169If an error can be associated to a particular point in the requested GraphQL
154- document, it should contain an entry with the key ` locations ` with a list of
155- locations, where each location is a map with the keys ` line ` and ` column ` , both
156- positive numbers starting from ` 1 ` which describe the beginning of an associated
157- syntax element.
170+ document, it should contain an entry with the key {" locations"} with a list of
171+ locations, where each location is a map with the keys {" line"} and {" column"},
172+ both positive numbers starting from ` 1 ` which describe the beginning of an
173+ associated syntax element.
158174
159175If an error can be associated to a particular field in the GraphQL result, it
160- must contain an entry with the key ` path ` that details the path of the response
161- field which experienced the error. This allows clients to identify whether a
162- ` null ` result is intentional or caused by a runtime error. The value of this
163- _ path entry _ is described in the [ Path ] ( #sec-Path ) section .
176+ must contain an entry with the key {" path"} with a _ response path _ which
177+ describes which _ response position _ which experienced the error. This allows
178+ clients to identify whether a {null} resolved result is a true value or the
179+ result of an _ execution error _ .
164180
165181For example, if fetching one of the friends' names fails in the following
166182operation:
@@ -290,21 +306,6 @@ discouraged.
290306}
291307```
292308
293- ### Path
294-
295- :: A _ path entry_ is an entry within an _ error result_ that indicates the
296- _ response position_ at which the error occurred.
297-
298- The value for a _ path entry_ must be a list of path segments starting at the
299- root of the response and ending with the field to be associated with. Path
300- segments that represent fields must be strings, and path segments that represent
301- list indices must be 0-indexed integers. If a path segment is associated with an
302- aliased field it must use the aliased name, since it represents a path in the
303- response, not in the request.
304-
305- When the _ path entry_ is present on an _ error result_ , it identifies the
306- response field which experienced the error.
307-
308309## Serialization Format
309310
310311GraphQL does not require a specific serialization format. However, clients
0 commit comments