You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/learn/debug-errors.mdx
+20-10Lines changed: 20 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -74,10 +74,17 @@ The HTTP layer succeeded, but the GraphQL operation produced errors.
74
74
75
75
### Common causes
76
76
77
+
- Runtime errors during execution
78
+
- Violating schema constraints (e.g. returning the wrong data type, or `null` in a non-nullable position)
79
+
80
+
Older servers and clients (those not using
81
+
`Content-Type: application/graphql-response+json`) may also use 200 OK in the case of
82
+
complete request failure (no `data`). Common causes include:
83
+
77
84
- Querying a field that doesn't exist
78
85
- Passing incorrect arguments to a field
79
-
-Violating schema constraints, such as non-nullability
80
-
-Runtime errors during execution
86
+
-Omitting a selection set on a non-leaf field
87
+
-Failure to specify the `operationName` when multiple operations exist in the request
81
88
82
89
### How to debug
83
90
@@ -114,18 +121,21 @@ validation errors differently. When in doubt, use error codes supported by the s
114
121
115
122
## Understanding GraphQL response formats
116
123
117
-
Most GraphQL servers return responses using the `application/json` media type. However,
118
-
the [GraphQL over HTTP spec](https://graphql.github.io/graphql-over-http/draft/) recommends
119
-
using a more specific type: `application/graphql-response+json`.
124
+
Traditionally, GraphQL servers have returned responses using the `application/json` media type.
125
+
However, the [GraphQL over HTTP spec](https://graphql.github.io/graphql-over-http/draft/) recommends
126
+
that clients request (and servers respond with) a more specific type: `application/graphql-response+json`.
120
127
121
-
This media type identifies the payload as a GraphQL response and helps clients
122
-
distinguish it from other types of JSON.
128
+
This newer media type identifies the payload as a GraphQL response and helps clients
129
+
distinguish it from other types of JSON, making the response safe to process even if
130
+
it uses a non-2xx status code. A trusted proxy, gateway, or other intermediary
131
+
might describe an error using JSON, but would never do so using `application/graphql-response+json`
132
+
unless it was a valid GraphQL response.
123
133
124
134
### What to know
125
135
126
-
- Servers may respond with `application/graphql-response+json`instead of
136
+
- Servers may respond with `application/graphql-response+json`or
127
137
`application/json`.
128
-
- Clients can request this media type using the `Accept` header: `Accept: application/graphql-response+json`
129
-
- This content type is optional, but support for it is growing.
138
+
- Clients can request this media type using the `Accept` header: `Accept: application/graphql-response+json, application/json;q=0.9` (prefer the new media type over the old one, but accept both)
139
+
- This content type is recommended, and support for it is growing.
130
140
- If your client uses content negotiation, ensure your server can response with the appropriate
0 commit comments