-
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
Throwing an Error doesn't cause an Error to be thrown #31
Comments
This issue is fixed by removing this line: https://github.com/benawad/apollo-mocked-provider/blob/master/src/createApolloMockedProvider.tsx#L52 However, this line was added for a reason: We could replace it with the |
I'm good if you want to add the breaking change |
@lorensr what does your server return when there is an error? What type of errors trigger the I am having a hard time finding a definitive reference on this but in my experience a lot of errors do not trigger the catch and just return an ApolloError in the mutation result. I think that is what the current code simulates and for me it seemed to match behavior in "real life" (but this is a confusing area for sure).
|
@sarfata I imagine many people either set the errorPolicy and/or use an error link to catch errors, in which case a mutation promise wouldn't reject. But if the errorPolicy is
https://www.apollographql.com/docs/react/api/core/ApolloClient/#ApolloClient.mutate The code I use that results in a GraphQL error is {"data":{"removeReview":null},"errors":[{"locations":[{"column":35,"line":1}],"message":"unauthorized","path":["removeReview"]}]} |
Working on the test for the PR and ran into this: testing-library/react-testing-library#828 and I got dejavu 😆 |
Yeah sounds like this is a poorly documented behavior (or too flexible with |
🎉 This issue has been resolved in version 5.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I have the following in my app:
doMutation().catch(e => doSomething(e.graphQLErrors))
.doSomething()
is called.ApolloMockedProvider
custom resolver,doSomething()
is not called.Repro: https://github.com/lorensr/apollo-mocked-provider/tree/repro-no-throw
The below
console.log
is not called when runningnpm test -- -t "mock Mutation"
lorensr@1682ac4
The text was updated successfully, but these errors were encountered: