Errors
How the GraphQL API reports failures: the errors array, the extensions shape, and the shared error-code reference.
When a request fails, the GraphQL API reports it in the standard GraphQL
errors array. Each entry has a human-readable message and, under
extensions, a machine-readable code and the HTTP status that the same
failure returns over REST.
The error shape
A failed operation comes back with one or more entries in errors and a
null (or partial) data:
{
"errors": [
{
"message": "Not authorized for this library.",
"extensions": {
"code": "API_KEY_NOT_AUTHORIZED_FOR_LIBRARY",
"http": { "status": 404 }
}
}
],
"data": null
}message is a human-readable string you can show to end users.
extensions.code is the stable, machine-readable failure mode; dispatch on
it. extensions.http.status is the HTTP status the same coded error returns
over REST.
The HTTP status of the response itself can differ: many failures come back
with HTTP 200, so read the status from extensions.http.status. The code
and message match what REST returns for the same
failure.
Error codes
The REST error reference defines every code, its message, and its HTTP
status. A given failure produces the same extensions.code, message, and
extensions.http.status over GraphQL as it does over REST: