Open marktani opened 6 years ago
I thought it might be a good idea to explain the apollo-error
approach in more depth. That is why I compiled this blog post here: https://dev.to/andre/handling-errors-in-graphql--2ea3.
I'm happy to hear your thoughts :)
@akoenig I do uncontrolled like that too. The beauty is, I can wire Sentry/Raven for capturing errors in the error handler or helmet as in your article.
@morajabi Yeah, definitely. I do that too! Glad to see that this is moving to a common consensus ππͺ
IMHO having a middleware layer is super powerful. You can compose small functions together and therefore keep your resolvers βcleanβ. ππ½
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I used ApolloError and
const { ApolloError } = require('apollo-server-errors') throw new ApolloError(MSG, CODE)
and it worked well.
apollo-error
otoh, doesn't implement the latest spec (uses data
property instead of extensions
)
There has been some discussion about how to throw errors from resolvers properly.
An example that show cases different approaches that are considered best practice would be super helpful!
If anyone's interested in contributing such an example, feel free to ping me in Slack (my handle there is @nilan), happy to collaborate on this one! π