@@ -17,12 +17,12 @@ A GraphQL request returns either a _response_ or a _response stream_.
17
17
or mutation. A _ response_ must be a map.
18
18
19
19
If 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
21
21
the request completed without raising any errors, this entry must not be
22
22
present.
23
23
24
24
If 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
26
26
request failed before execution, due to a syntax error, missing information, or
27
27
validation error, this entry must not be present.
28
28
@@ -35,7 +35,7 @@ To ensure future changes to the protocol do not break existing services and
35
35
clients, the top level response map must not contain any entries other than the
36
36
three described above.
37
37
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
39
39
appear first when serialized to make it more clear when errors are present in a
40
40
response during debugging.
41
41
@@ -44,30 +44,29 @@ response during debugging.
44
44
:: A GraphQL request returns a _ response stream_ when the GraphQL operation is a
45
45
subscription. A _ response stream_ must be a stream of _ response_ .
46
46
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
56
48
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 >
61
52
62
53
:: A _ response position_ is a uniquely identifiable position in the response
63
54
data produced during execution. It is either a direct entry in the {resultMap}
64
55
of 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.
66
61
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.
69
67
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.
71
70
72
71
A single field execution may result in multiple response positions. For example,
73
72
@@ -82,27 +81,44 @@ A single field execution may result in multiple response positions. For example,
82
81
}
83
82
```
84
83
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 ` .
89
105
90
106
### Errors
91
107
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
93
109
the _ request_ , where each error is a map of data described by the error result
94
110
format below.
95
111
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.
99
115
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.
103
119
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
106
122
_ execution error_ was raised during execution.
107
123
108
124
** Request Errors**
@@ -114,9 +130,9 @@ to determine which operation to execute, or invalid input values for variables.
114
130
115
131
A request error is typically the fault of the requesting client.
116
132
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.
120
136
121
137
** Execution Errors**
122
138
@@ -136,31 +152,32 @@ An execution error is typically the fault of a GraphQL service.
136
152
137
153
An _ execution error_ must occur at a specific _ response position_ , and may occur
138
154
in 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 .
140
156
141
157
When 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
145
162
[ Handling Execution Errors] ( #sec-Handling-Execution-Errors ) ).
146
163
147
164
** Error Result Format**
148
165
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
150
167
description of the error intended for the developer as a guide to understand and
151
168
correct the error.
152
169
153
170
If 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.
158
175
159
176
If 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 _ .
164
181
165
182
For example, if fetching one of the friends' names fails in the following
166
183
operation:
@@ -290,21 +307,6 @@ discouraged.
290
307
}
291
308
```
292
309
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
-
308
310
## Serialization Format
309
311
310
312
GraphQL does not require a specific serialization format. However, clients
0 commit comments