-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Error handling and reporting in graphql is not yet standardized. The spec has errors handled outside of the schema. This is not ideal, because it is an implied protocol. Making the protocol explicit and discoverable is kind of the whole point of using graphql.
Apollo Server follows the spec and provides error types that are returned outside of the schema. I'm using that for the time being.
https://www.apollographql.com/docs/apollo-server/data/errors/
I'm opening this ticket as a place to collect links to error handling articles I've found, so we can explore other options later.
This appears to be the oldest article dealing with this. It suggests using union types as return types, allowing return of either data or error.
https://artsy.github.io/blog/2018/10/19/where-art-thou-my-error/
This one further explores this idea and is a little clearer.
https://sachee.medium.com/200-ok-error-handling-in-graphql-7ec869aec9bc
This one takes the union idea and adds interfaces to help smooth the introduction of new errors down the line.
https://blog.logrocket.com/handling-graphql-errors-like-a-champ-with-unions-and-interfaces/