prisma / prisma-examples

πŸš€ Ready-to-run Prisma example projects
https://www.prisma.io/docs/
Apache License 2.0
5.99k stars 1.41k forks source link

Example with different approaches for error handling #321

Open marktani opened 6 years ago

marktani commented 6 years ago

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! πŸ™Œ

akoenig commented 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 :)

morajabi commented 6 years ago

@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.

akoenig commented 6 years ago

@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β€œ. πŸ™ŒπŸ½

stale[bot] commented 5 years ago

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.

Jaikant commented 4 years ago

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)