Error
graphql/error
The graphql/error module is responsible for creating and formatting GraphQL errors
- You can import either from the graphql/errormodule, or from the rootgraphqlmodule
import { GraphQLError } from "graphql"
What is it
When Apollo server encounters error while processing a GQL operation, it responds to a client with an errors array containing each error that occurred.
Each error in the errors array has an extensions field that provides additional useful information
- error codeor- stracktracein development mode
Validation Regression in v4
Use Apollo v5 in lieu of v4. V4 introduced a regression where an invalid variables result in 200 status code instead of 400 status code.
For example, when an input variable of String is passed instead of Int, the variable coercion will fail without explicitly throwing error.
- Another example is unexpected nullor missing/incorrect fields on input objects