-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error handling within MockedProvider #4
Comments
I like that approach, I'd be happy to merge a pr for that. |
@NickTomlin I could use this too. Any reason you have not made a PR yet?
|
@sarfata thanks for merging! My wife and I recently welcomed a child so I haven't had any time to focus on this 😄 One issue that I did encounter (which was why I hadn't merged my initial work) is that errors thrown in mutation resolvers do not work as expected. By default, they caught by the error handler and also thrown by Apollo. Here's a reproduction ( The "fix" is to either specify an
If you add the |
Hey @NickTomlin Congrats on the baby! Sorry for the delay here. Just wanted to acknowledge and say that I will get around to doing that and pushing a new PR. Thanks for pointing this out. |
i have the problem when throw error in mutation, can this be fixed or i need to fork the repo and add the defaultOptions for errorPolicy. |
@netweng happy to merge a pr |
Here's a problem I'm having with this feature: #31 |
The current
createApolloErrorProvider
approach has a separate "throw an error for all requests". This is useful for inspecting the behavior of errors on initial load, but breaks down for me when I have a view that may render some data with a query (like a list of items) and execute another query/mutation on that data.I'd prefer to be able to control the error handling within my custom resolvers. I've taken a crack at it here. Here is a snippet of usage:
This would allow a
todos
query to execute, and then throw an error whentodo(id: ID)
is executed. Optionally, a resolver can inspect its arguments and conditionally throw an error. This would allow for a more natural way of handling complex error scenarios.The text was updated successfully, but these errors were encountered: