Skip to content
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

useMutation - onError callbacks both called in hook and mutate options #10287

Closed
leepowelldev opened this issue Nov 15, 2022 · 3 comments · Fixed by #10425
Closed

useMutation - onError callbacks both called in hook and mutate options #10287

leepowelldev opened this issue Nov 15, 2022 · 3 comments · Fixed by #10425
Assignees

Comments

@leepowelldev
Copy link

leepowelldev commented Nov 15, 2022

When using useMutation and setting a callback handler in the hook options as well as a handler in the mutate function options, both handlers are called when an error occurs. According to the docs this should not happen.

If you provide the same option to both useMutation and your mutate function, the mutate function's value takes precedence.

Intended outcome:
Only the mutate function onError callback should be called.

Actual outcome:
Both callback handlers are called.

How to reproduce the issue:
Repo can be found here reproducing the issue:
https://github.com/leepowelldev/apollo-client-bug-2

Versions
System:
OS: macOS 13.0.1
Binaries:
Node: 18.12.1 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.19.2 - /usr/local/bin/npm
Browsers:
Chrome: 107.0.5304.110
Edge: 107.0.1418.42
Firefox: 106.0.5
Safari: 16.1
npmPackages:
@apollo/client: ^3.7.1 => 3.7.1

Screenshot 2022-11-15 at 21 03 55

@jerelmiller
Copy link
Member

Hey @leepowelldev 👋 !

Thanks for reporting this! I've got a PR up (#10425) to fix this issue. This will likely go out with our next patch release.

@leepowelldev
Copy link
Author

Thanks!

@jerelmiller
Copy link
Member

Hey @leepowelldev 👋 !

Version v3.7.4 was just released which contains a fix for this issue. Thanks again for submitting the issue!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants