-
Notifications
You must be signed in to change notification settings - Fork 538
Swallow GraphQL errors by Express #803
Comments
So this issue was opened in April. Did you find a solution to this? I'm running into this right now and it's looking pretty dire. |
@divmgl No sorry, I let i go |
Hi, |
Trying my best to understand the exact scenario you are trying to solve & I know this library is deprecated but I run it in production with graphql-shield and battled with error handling myself so much that I patched it for our use case. Some possibly helpful tips although untested: Instead of filtering based on the message, use a custom error with an errorType like so:
This will come through to your customFormatErrorFn, and you can then handle it based on the type. The next part is returning a valid GraphQL response. Look at the function graphqlMiddleware inside the the library index.ts and you will see how they construct it:
I personally have a lot more custom logic painfully wired in to the library, but if you're stuck using this library, maybe it will help you find the right answer for you |
This library has been deprecated and this repo will be archived soon. It has been superseded by Furthermore, if you seek a fully-featured, well-maintained and performant server - I heavily recommend GraphQL Yoga! |
Hi
I'm having issues using a simple express error handler middleware to swallow errors thrown in GraphQL resolvers
For example, I would have:
GQLside
Express side
What I need, is when inside the resolver I throw the
Some Error
, Express swallows it inside it's middleware.It does not work
The only way I managed to do it, is by throwing inside the
customFormatErrorFn
function:If I do that, the Express middleware is being called.
But GraphQL returns a bad formatted response
I don't understand how I can simply manage GraphQL errors through Express. I'm certainly doing something wrong
My final goal is to catch those errors before they are sent to the client (to chose if I log them for example)
The text was updated successfully, but these errors were encountered: