Skip to content

Commit 0bbd856

Browse files
committed
lift response position to top section
1 parent f831eb7 commit 0bbd856

File tree

2 files changed

+69
-66
lines changed

2 files changed

+69
-66
lines changed

Diff for: spec/Section 6 -- Execution.md

+3-2
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.

Diff for: spec/Section 7 -- Response.md

+66-64
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,29 @@ 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.
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
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_.
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

7271
A 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
93109
the _request_, where each error is a map of data described by the error result
94110
format 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

115131
A 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

137153
An _execution error_ must occur at a specific _response position_, and may occur
138154
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.
140156

141157
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
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
150167
description of the error intended for the developer as a guide to understand and
151168
correct the error.
152169

153170
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.
158175

159176
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_.
164181

165182
For example, if fetching one of the friends' names fails in the following
166183
operation:
@@ -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

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

0 commit comments

Comments
 (0)