-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Unify error behavior of client.mutate and update its type
#12475
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
Unify error behavior of client.mutate and update its type
#12475
Conversation
🦋 Changeset detectedLatest commit: e2c12e1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
commit: |
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
size-limit report 📦
|
client.mutateclient.mutate and update its type
7a5edf4 to
9e97db8
Compare
9e97db8 to
6b1bfc8
Compare
phryneas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good change, let's get this in!
Closes #12455
Fixes #9065
Fixes #7167
Partially addresses #12427
Updates
client.mutateto return aMutateResulttype instead of aFetchResult.FetchResultis the raw response type we expect from the link chain. Because of this, we were not able to apply error unification to mutations since there is noerrorproperty on this type.This change swaps
errorsforerrorand applies the same error unification behavior to mutations as was done to queries in #12457. Network errors are now subject to theerrorPolicyand will resolve the mutation promise if theerrorPolicyis notnone.This change also fixes a long-standing bug with
useMutationwhere passing anonErrorcallback would resolve the promise returned from the mutation whenerrorPolicywasnone. These errors are now rejected to ensure the mutation behaves the same whether or notonErrorwas provided.