Skip to content

Commit 82be7a0

Browse files
committed
lift response position to top section
1 parent f831eb7 commit 82be7a0

File tree

2 files changed

+52
-55
lines changed

2 files changed

+52
-55
lines changed

spec/Section 6 -- Execution.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,9 @@ MergeSelectionSets(fields):
814814
</a>
815815

816816
An _execution error_ is an error raised during field execution, value resolution
817-
or coercion, at a specific _response position_. While these errors should be
818-
reported in the response, they are "handled" by producing a partial response.
817+
or coercion, at a specific _response position_. While these errors must be
818+
reported in the response, they are "handled" by producing partial {"data"} in
819+
the _response_.
819820

820821
Note: This is distinct from a _request error_ which results in a response with
821822
no data.

spec/Section 7 -- Response.md

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ A GraphQL request returns either a _response_ or a _response stream_.
1717
or mutation. A _response_ must be a map.
1818

1919
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
2121
the request completed without raising any errors, this entry must not be
2222
present.
2323

2424
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
2626
request failed before execution, due to a syntax error, missing information, or
2727
validation 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
3535
clients, the top level response map must not contain any entries other than the
3636
three 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
3939
appear first when serialized to make it more clear when errors are present in a
4040
response during debugging.
4141

@@ -44,30 +44,27 @@ response during debugging.
4444
:: A GraphQL request returns a _response stream_ when the GraphQL operation is a
4545
subscription. 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.
56-
57-
If an error was raised during the execution that prevented a valid response, the
58-
`data` entry in the response should be `null`.
47+
### Response Position
5948

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
6354
data produced during execution. It is either a direct entry in the {resultMap}
6455
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_.
6657

67-
The response data is the result of accumulating the result of all response
68-
positions during execution.
58+
:: A _response path_ uniquely identifies a _response position_ via a list of path segments (response keys or list indicies) starting at the root of the response and ending with the associated response position.
59+
60+
The value for a _response path_ must be a list of path segments. Path
61+
segments that represent field response keys must be strings, and path segments that represent
62+
list indices must be 0-indexed integers. If a path segment is associated with an
63+
aliased field it must use the aliased name, since it represents a path in the
64+
response, not in the request.
6965

70-
Each _response position_ is uniquely identifiable via a _path entry_.
66+
When a _response path_ is present on an _error result_, it identifies the
67+
_response position_ which raised the error.
7168

7269
A single field execution may result in multiple response positions. For example,
7370

@@ -87,22 +84,38 @@ The hero's name would be found in the _response position_ identified by
8784
`["hero", "friends"]`, the hero's first friend at `["hero", "friends", 0]` and
8885
that friend's name at `["hero", "friends", 0, "name"]`.
8986

87+
### Data
88+
89+
The {"data"} entry in the response will be the result of the execution of the
90+
requested operation. If the operation was a query, this output will be an object
91+
of the query root operation type; if the operation was a mutation, this output
92+
will be an object of the mutation root operation type.
93+
94+
The response data is the result of accumulating the resolved result of all
95+
response positions during execution.
96+
97+
If an error was raised before execution begins, the {"data"} entry should not be
98+
present in the response.
99+
100+
If an error was raised during the execution that prevented a valid response, the
101+
{"data"} entry in the response should be `null`.
102+
90103
### Errors
91104

92-
The `errors` entry in the response is a non-empty list of errors raised during
105+
The {"errors"} entry in the response is a non-empty list of errors raised during
93106
the _request_, where each error is a map of data described by the error result
94107
format below.
95108

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
109+
If present, the {"errors"} entry in the response must contain at least one error.
110+
If no errors were raised during the request, the {"errors"} entry must not be
98111
present in the response.
99112

100-
If the `data` entry in the response is not present, the `errors` entry must be
113+
If the {"data"} entry in the response is not present, the {"errors"} entry must be
101114
present. It must contain at least one _request error_ indicating why no data was
102115
able to be returned.
103116

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
117+
If the {"data"} entry in the response is present (including if it is the value
118+
{null}), the {"errors"} entry must be present if and only if one or more
106119
_execution error_ was raised during execution.
107120

108121
**Request Errors**
@@ -114,8 +127,8 @@ to determine which operation to execute, or invalid input values for variables.
114127

115128
A request error is typically the fault of the requesting client.
116129

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
130+
If a request error is raised, the {"data"} entry in the response must not be
131+
present, the {"errors"} entry must include the error, and request execution should
119132
be halted.
120133

121134
**Execution Errors**
@@ -136,31 +149,29 @@ An execution error is typically the fault of a GraphQL service.
136149

137150
An _execution error_ must occur at a specific _response position_, and may occur
138151
in any response position. The response position of an execution error is
139-
indicated via the error's `path` _path entry_.
152+
indicated via a _response path_ in the error response's {"path"} entry.
140153

141154
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
155+
response position must not be present within the _response_ {"data"} entry (except
156+
{null}), and the {"errors"} entry must include the error. Nested execution is
144157
halted and sibling execution attempts to continue, producing partial result (see
145158
[Handling Execution Errors](#sec-Handling-Execution-Errors)).
146159

147160
**Error Result Format**
148161

149-
Every error must contain an entry with the key `message` with a string
162+
Every error must contain an entry with the key {"message"} with a string
150163
description of the error intended for the developer as a guide to understand and
151164
correct the error.
152165

153166
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
167+
document, it should contain an entry with the key {"locations"} with a list of
168+
locations, where each location is a map with the keys {"line"} and {"column"}, both
156169
positive numbers starting from `1` which describe the beginning of an associated
157170
syntax element.
158171

159172
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.
173+
must contain an entry with the key {"path"} with a _response path_ which describes which _response position_ which experienced the error. This allows clients to identify whether a
174+
{null} resolved result is a true value or the result of an _execution error_.
164175

165176
For example, if fetching one of the friends' names fails in the following
166177
operation:
@@ -290,21 +301,6 @@ discouraged.
290301
}
291302
```
292303

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-
308304
## Serialization Format
309305

310306
GraphQL does not require a specific serialization format. However, clients

0 commit comments

Comments
 (0)