Top GraphQL Errors and How to fix them

query {
author {
id
name
}
}
{
"data": [{ id: 1, name: "Praveen"}],
"errors": []
}

Server Problems / Network errors

  • Bad request (400)
  • Unauthorized (401)
  • Gateway errors (5xx)

Client side problems — Validation rules of GraphQL Query

  • malformed query
  • syntax or schema logic
  • variables and fragments not defined properly.
{
"errors": [
{
"extensions": {
"path": "$.variableValues",
"code": "validation-failed"
},
"message": "unexpected variables in variableValues: products"
}
]
}

Top-level errors

Field level errors

{
“errors”: [{
“extensions”: {
“path”: “$.selectionSet.dogs.selectionSet.name”,
“code”: “validation-failed”
},
“message”: “field \”name\” not found in type: ‘dogs’”
}]
}

GraphQL Subscription Errors

  • websocket connection could not be initalised. This needs a check with the URL of the websocket connection; note that websocket URLs start with ws or wss and not https.
  • invalid http upgrade (this could happen when http(s) is used for a websocket connection and the right connection split is not configured for ws)
  • connectionParams not passed for authorization headers. If you are using a JWT token, it needs to be passed via connectionParams using the GraphQL Client.

Resources

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store