@@ -9,40 +9,66 @@ the case that any _execution error_ was raised and replaced with {null}.
9
9
10
10
## Response Format
11
11
12
- A GraphQL request returns either a _ response_ or a _ response stream_ .
12
+ :: A GraphQL request returns a _ response_ . A _ response_ is either an _ execution
13
+ result_ , a _ response stream_ , or a _ request error result_ .
13
14
14
- ### Response
15
+ ### Execution Result
15
16
16
- :: A GraphQL request returns a _ response_ when the GraphQL operation is a query
17
- or mutation. A _ response_ must be a map.
17
+ :: A GraphQL request returns an _ execution result_ when the GraphQL operation is
18
+ a query or mutation and the request included execution. Additionally, for each
19
+ event in a subscription's _ source stream_ , the _ response stream_ will emit an
20
+ _ execution result_ .
18
21
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
21
- the request completed without raising any errors, this entry must not be
22
- present.
22
+ An _ execution result_ must be map.
23
23
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
26
- request failed before execution, due to a syntax error, missing information, or
27
- validation error, this entry must not be present.
24
+ The _ execution result_ must contain an entry with key {"data"}. The value of
25
+ this entry is described in the "Data" section.
28
26
29
- The response map may also contain an entry with key ` extensions ` . This entry, if
30
- set, must have a map as its value. This entry is reserved for implementers to
31
- extend the protocol however they see fit, and hence there are no additional
32
- restrictions on its contents.
27
+ If execution raised any errors, the _ execution result_ must contain an entry
28
+ with key {"errors"}. The value of this entry must be a non-empty list of
29
+ _ execution error_ raised during execution. Each error must be a map as described
30
+ in the "Errors" section below. If the request completed without raising any
31
+ errors, this entry must not be present.
33
32
34
- To ensure future changes to the protocol do not break existing services and
35
- clients, the top level response map must not contain any entries other than the
36
- three described above .
33
+ Note: When {"errors"} is present in a _ execution result _ , it may be helpful for
34
+ it to appear first when serialized to make it more apparent that errors are
35
+ present .
37
36
38
- Note: When {"errors"} is present in the response, it may be helpful for it to
39
- appear first when serialized to make it more clear when errors are present in a
40
- response during debugging.
37
+ The _ execution result_ may also contain an entry with key ` extensions ` . The
38
+ value of this entry is described in the "Extensions" section.
41
39
42
40
### Response Stream
43
41
44
42
:: A GraphQL request returns a _ response stream_ when the GraphQL operation is a
45
- subscription. A _ response stream_ must be a stream of _ response_ .
43
+ subscription and the request included execution. A response stream must be a
44
+ stream of _ execution result_ .
45
+
46
+ ### Request Error Result
47
+
48
+ :: A GraphQL request returns a _ request error result_ when one or more _ request
49
+ error_ are raised, causing the request to fail before execution. This request
50
+ will result in no response data.
51
+
52
+ Note: A _ request error_ may be raised before execution due to missing
53
+ information, syntax errors, validation failure, coercion failure, or any other
54
+ reason the implementation may determine should prevent the request from
55
+ proceeding.
56
+
57
+ A _ request error result_ must be a map.
58
+
59
+ The _ request error result_ map must contain an entry with key {"errors"}. The
60
+ value of this entry must be a non-empty list of _ request error_ raised during
61
+ the _ request_ . It must contain at least one _ request error_ indicating why no
62
+ data was able to be returned. Each error must be a map as described in the
63
+ "Errors" section below.
64
+
65
+ Note: It may be helpful for the {"errors"} key to appear first when serialized
66
+ to make it more apparent that errors are present.
67
+
68
+ The _ request error result_ map must not contain an entry with key {"data"}.
69
+
70
+ The _ request error result_ map may also contain an entry with key ` extensions ` .
71
+ The value of this entry is described in the "Extensions" section.
46
72
47
73
### Response Position
48
74
@@ -89,37 +115,25 @@ found at `["hero", "friends"]`, the hero's first friend at
89
115
90
116
### Data
91
117
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.
118
+ The {"data"} entry in the _ execution result _ will be the result of the execution
119
+ of the requested operation. If the operation was a query, this output will be an
120
+ object of the query root operation type; if the operation was a mutation, this
121
+ output will be an object of the mutation root operation type.
96
122
97
123
The response data is the result of accumulating the resolved result of all
98
124
response positions during execution.
99
125
100
- If an error was raised before execution begins, the {"data"} entry should not be
101
- present in the response.
126
+ If an error was raised before execution begins, the _ response _ must be a
127
+ _ request error result _ which will result in no response data .
102
128
103
129
If an error was raised during the execution that prevented a valid response, the
104
130
{"data"} entry in the response should be ` null ` .
105
131
106
132
### Errors
107
133
108
- The {"errors"} entry in the response is a non-empty list of errors raised during
109
- the _ request_ , where each error is a map of data described by the error result
110
- format below.
111
-
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.
115
-
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.
119
-
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
122
- _ execution error_ was raised during execution.
134
+ The {"errors"} entry in the _ execution result_ or _ request error result_ is a
135
+ non-empty list of errors raised during the _ request_ , where each error is a map
136
+ of data described by the error result format below.
123
137
124
138
** Request Errors**
125
139
@@ -130,9 +144,9 @@ to determine which operation to execute, or invalid input values for variables.
130
144
131
145
A request error is typically the fault of the requesting client.
132
146
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.
147
+ If a request error is raised, the _ response _ must be a _ request error result _ .
148
+ The {"data "} entry in this map must not be present, the {"errors"} entry must
149
+ include the error, and request execution should be halted.
136
150
137
151
** Execution Errors**
138
152
@@ -307,6 +321,20 @@ discouraged.
307
321
}
308
322
```
309
323
324
+ ### Extensions
325
+
326
+ The {"extensions"} entry in an _ execution result_ or _ request error result_ , if
327
+ set, must have a map as its value. This entry is reserved for implementers to
328
+ extend the protocol however they see fit, and hence there are no additional
329
+ restrictions on its contents.
330
+
331
+ ### Additional Entries
332
+
333
+ To ensure future changes to the protocol do not break existing services and
334
+ clients, the _ execution result_ and _ request error result_ maps must not contain
335
+ any entries other than those described above. Clients must ignore any entries
336
+ other than those described above.
337
+
310
338
## Serialization Format
311
339
312
340
GraphQL does not require a specific serialization format. However, clients
0 commit comments