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