@@ -10,71 +10,75 @@ the case that any _field error_ was raised on a field and was replaced with
10
10
11
11
## Response Format
12
12
13
- A GraphQL request returns either a _ response_ or a _ response stream_ .
13
+ :: A GraphQL _ response_ the returned result of a GraphQL _ request_ . A _ response_
14
+ is either a _ response map_ or a _ response stream_ .
14
15
15
- ### Response
16
+ ### Response Map
16
17
17
- :: A GraphQL request returns a _ response_ when the GraphQL operation is a query
18
- or mutation. A _ response_ must be a map.
18
+ :: A GraphQL request returns a _ response map_ when the GraphQL operation is a
19
+ query or mutation. When the GraphQL operation is a subscription, the GraphQL
20
+ request returns a _ response map_ if a _ request error_ is raised. A response map
21
+ must be a map.
19
22
20
- If the request raised any errors, the response map must contain an entry with
23
+ If the request raised any errors, the _ response map _ must contain an entry with
21
24
key ` errors ` . The value of this entry is described in the "Errors" section. If
22
25
the request completed without raising any errors, this entry must not be
23
26
present.
24
27
25
- If the request included execution, the response map must contain an entry with
28
+ If the request included execution, the _ response map _ must contain an entry with
26
29
key ` data ` . The value of this entry is described in the "Data" section. If the
27
30
request failed before execution, due to a syntax error, missing information, or
28
31
validation error, this entry must not be present.
29
32
30
- The response map may also contain an entry with key ` extensions ` . This entry, if
31
- set, must have a map as its value. This entry is reserved for implementers to
33
+ The _ response map _ may also contain an entry with key ` extensions ` . This entry,
34
+ if set, must have a map as its value. This entry is reserved for implementers to
32
35
extend the protocol however they see fit, and hence there are no additional
33
36
restrictions on its contents.
34
37
35
38
To ensure future changes to the protocol do not break existing services and
36
- clients, the top level response map must not contain any entries other than the
37
- three described above.
39
+ clients, the top level _ response map _ must not contain any entries other than
40
+ the three described above.
38
41
39
- Note: When ` errors ` is present in the response , it may be helpful for it to
40
- appear first when serialized to make it more clear when errors are present in a
41
- response during debugging.
42
+ Note: When ` errors ` is present in the _ response map _ , it may be helpful for it
43
+ to appear first when serialized to make it more clear when errors are present in
44
+ a response map during debugging.
42
45
43
46
### Response Stream
44
47
45
48
:: A GraphQL request returns a _ response stream_ when the GraphQL operation is a
46
- subscription. A _ response stream_ must be a stream of _ response_ .
49
+ subscription and a _ request error_ is not raised. A response stream must be a
50
+ stream of _ response map_ .
47
51
48
52
### Data
49
53
50
- The ` data ` entry in the response will be the result of the execution of the
51
- requested operation. If the operation was a query, this output will be an object
52
- of the query root operation type; if the operation was a mutation, this output
53
- will be an object of the mutation root operation type.
54
+ The ` data ` entry in the _ response map _ will be the result of the execution of
55
+ the requested operation. If the operation was a query, this output will be an
56
+ object of the query root operation type; if the operation was a mutation, this
57
+ output will be an object of the mutation root operation type.
54
58
55
59
If an error was raised before execution begins, the ` data ` entry should not be
56
- present in the response .
60
+ present in the _ response map _ .
57
61
58
- If an error was raised during the execution that prevented a valid response, the
59
- ` data ` entry in the response should be ` null ` .
62
+ If an error was raised during execution that propagated to the operation root,
63
+ the ` data ` entry in the _ response map _ should be ` null ` .
60
64
61
65
### Errors
62
66
63
- The ` errors ` entry in the response is a non-empty list of errors raised during
64
- the _ request_ , where each error is a map of data described by the error result
65
- format below.
67
+ The ` errors ` entry in the _ response map _ is a non-empty list of errors raised
68
+ during the _ request_ , where each error is a map of data described by the error
69
+ result format below.
66
70
67
- If present, the ` errors ` entry in the response must contain at least one error.
68
- If no errors were raised during the request, the ` errors ` entry must not be
69
- present in the response.
71
+ If present, the ` errors ` entry in the _ response map _ must contain at least one
72
+ error. If no errors were raised during the request, the ` errors ` entry must not
73
+ be present in the response map .
70
74
71
- If the ` data ` entry in the response is not present, the ` errors ` entry must be
72
- present. It must contain at least one _ request error_ indicating why no data was
73
- able to be returned.
75
+ If the ` data ` entry in the _ response map _ is not present, the ` errors ` entry
76
+ must be present. It must contain at least one _ request error_ indicating why no
77
+ data was able to be returned.
74
78
75
- If the ` data ` entry in the response is present (including if it is the value
76
- {null}), the ` errors ` entry must be present if and only if one or more _ field
77
- error_ was raised during execution.
79
+ If the ` data ` entry in the _ response map _ is present (including if it is the
80
+ value {null}), the ` errors ` entry must be present if and only if one or more
81
+ _ field error_ was raised during execution.
78
82
79
83
** Request Errors**
80
84
@@ -85,7 +89,7 @@ to determine which operation to execute, or invalid input values for variables.
85
89
86
90
A request error is typically the fault of the requesting client.
87
91
88
- If a request error is raised, the ` data ` entry in the response must not be
92
+ If a request error is raised, the ` data ` entry in the _ response map _ must not be
89
93
present, the ` errors ` entry must include the error, and request execution should
90
94
be halted.
91
95
@@ -99,8 +103,8 @@ A field error is typically the fault of a GraphQL service.
99
103
100
104
If a field error is raised, execution attempts to continue and a partial result
101
105
is produced (see [ Handling Field Errors] ( #sec-Handling-Field-Errors ) ). The
102
- ` data ` entry in the response must be present. The ` errors ` entry should include
103
- this error.
106
+ ` data ` entry in the _ response map _ must be present. The ` errors ` entry should
107
+ include this error.
104
108
105
109
** Error Result Format**
106
110
0 commit comments