Apollo Error Handling
This project demonstrates using Apollo's formatError to customise error responses from Apollo server.
Usage
Install dependencies
npm install
Run serverless offline
npm start
View the graphql GUI at http://localhost:3000/
Examples
- A valid response
query ExampleQuery {
hello
}
- An internally thrown error
query ExampleQuery {
error
}
- A GraphQL error
query ExampleQuery {
notfound
}
- Custom Apollo error codes
You can use any custom apollo error code.
query ExampleQuery {
userWithID(id: 0) {
id
name
}
}