@@ -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
@@ -82,27 +81,44 @@ A single field execution may result in multiple response positions. For example,
8281}
8382```
8483
85- The hero's name would be found in the _ response position_ identified by
86- ` ["hero", "name"] ` . The List of the hero's friends would be found at
87- ` ["hero", "friends"] ` , the hero's first friend at ` ["hero", "friends", 0] ` and
88- that friend's name at ` ["hero", "friends", 0, "name"] ` .
84+ The hero's name would be found in the _ response position_ identified by the
85+ _ response path_ ` ["hero", "name"] ` . The List of the hero's friends would be
86+ found at ` ["hero", "friends"] ` , the hero's first friend at
87+ ` ["hero", "friends", 0] ` and that friend's name at
88+ ` ["hero", "friends", 0, "name"] ` .
89+
90+ ### Data
91+
92+ The {"data"} entry in the response will be the result of the execution of the
93+ requested operation. If the operation was a query, this output will be an object
94+ of the query root operation type; if the operation was a mutation, this output
95+ will be an object of the mutation root operation type.
96+
97+ The response data is the result of accumulating the resolved result of all
98+ response positions during execution.
99+
100+ If an error was raised before execution begins, the {"data"} entry should not be
101+ present in the response.
102+
103+ If an error was raised during the execution that prevented a valid response, the
104+ {"data"} entry in the response should be ` null ` .
89105
90106### Errors
91107
92- The ` errors ` entry in the response is a non-empty list of errors raised during
108+ The {" errors"} entry in the response is a non-empty list of errors raised during
93109the _ request_ , where each error is a map of data described by the error result
94110format below.
95111
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.
112+ If present, the {" errors"} entry in the response must contain at least one
113+ error. If no errors were raised during the request, the {" errors"} entry must
114+ not be present in the response.
99115
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.
116+ If the {" data"} entry in the response is not present, the {" errors"} entry must
117+ be present. It must contain at least one _ request error_ indicating why no data
118+ was able to be returned.
103119
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
120+ If the {" data"} entry in the response is present (including if it is the value
121+ {null}), the {" errors"} entry must be present if and only if one or more
106122_ execution error_ was raised during execution.
107123
108124** Request Errors**
@@ -114,9 +130,9 @@ to determine which operation to execute, or invalid input values for variables.
114130
115131A request error is typically the fault of the requesting client.
116132
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.
133+ If a request error is raised, the {" data"} entry in the response must not be
134+ present, the {" errors"} entry must include the error, and request execution
135+ should be halted.
120136
121137** Execution Errors**
122138
@@ -136,31 +152,32 @@ An execution error is typically the fault of a GraphQL service.
136152
137153An _ execution error_ must occur at a specific _ response position_ , and may occur
138154in any response position. The response position of an execution error is
139- indicated via the error's ` path ` _ path entry _ .
155+ indicated via a _ response path _ in the error response 's {" path"} entry .
140156
141157When 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
158+ response position must not be present within the _ response_ {"data"} entry
159+ (except {null}), and the {"errors"} entry must include the error. Nested
160+ execution is halted and sibling execution attempts to continue, producing
161+ partial result (see
145162[ Handling Execution Errors] ( #sec-Handling-Execution-Errors ) ).
146163
147164** Error Result Format**
148165
149- Every error must contain an entry with the key ` message ` with a string
166+ Every error must contain an entry with the key {" message"} with a string
150167description of the error intended for the developer as a guide to understand and
151168correct the error.
152169
153170If 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.
171+ document, it should contain an entry with the key {" locations"} with a list of
172+ locations, where each location is a map with the keys {" line"} and {" column"},
173+ both positive numbers starting from ` 1 ` which describe the beginning of an
174+ associated syntax element.
158175
159176If 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 .
177+ must contain an entry with the key {" path"} with a _ response path _ which
178+ describes the _ response position _ which raised the error. This allows clients to
179+ identify whether a {null} resolved result is a true value or the result of an
180+ _ execution error _ .
164181
165182For example, if fetching one of the friends' names fails in the following
166183operation:
@@ -290,21 +307,6 @@ discouraged.
290307}
291308```
292309
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-
308310## Serialization Format
309311
310312GraphQL does not require a specific serialization format. However, clients
0 commit comments