There was a undescribed "Breaking change" in useMutation hook
See original GitHub issueSince this commit there was a “breaking change” in the useMutation
hook.
Intended outcome: When doing the following code:
const { errors } = await doMutation()
errors
was filled if there was an error from the API
Actual outcome: Error is now thrown instead of returned.
How to reproduce the issue:
// Make sure this mutation returns a error
const { errors } = await doMutation()
// Errors wont be called since
console.log(errors)
Versions Everything after 3.4.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
The useMutation hook | Lift-off IV: Mutations
Inside the TrackCard component, we'll start off by calling the hook. It takes in the mutation we set up earlier, INCREMENT_TRACK_VIEWS , as...
Read more >Relay with hook useMutation get error: Invalid hook call. ...
I'm trying to commit a relay mutation of using the useMutation hook, but got the error: Error: Invalid hook call. Hooks can only...
Read more >react-apollo-hooks | Yarn - Package Manager
BREAKING CHANGES · useMutation returns tuple with result instead of just returning a mutating function · now Apollo Client >= 2.6.0 is required...
Read more >[Solved] Running a mutation from an event handler
It IS inside of a function. I've tried instead of { } in const { setDomain } = useMutation . What am I...
Read more >apollo/client
Implement useFragment_experimental hook, which represents a lightweight live ... whose addition in #8699 was a breaking change (starting in Apollo Client ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @TriPSs,
I’m having the same problem. It is in my opinion an unexpected behavior because when i can get an error returned i expect that it does not throw an error. In addition it isn’t documented:
Currently my solution looks like this:
This is a typesafe solution providing the same result as @TriPSs and me expect
Yea, if the line where it now throws the error would return it just like it does a couple of lines above it the behaviour would be how it was.
Currently we have it this was in a lot of places, so if this behaviour won’t work anymore we would have to refractor all off those and add empty try catches to it otherwise our error reporting tool will send un needed messages.