Variables set on mutate function override one set on useMutation hook
See original GitHub issueIntended outcome:
Variables passed to mutate
function and variables set on useMutation
merged together into one object
Actual outcome:
Variables passed to mutate
function override what was set on useMutation
How to reproduce the issue:
const [updateThing] = useMutation(UPDATE_THIS_GQL, {
variables: {
id: thingId
}
});
...
const result = await updateThing({
variables: {
...otherValuesButId
}
});
Versions
I believe that this was introduced by https://github.com/apollographql/apollo-client/commit/b273d033d6bebddb5fcf4e501e248a0e773e452b, specifically by removing this code:
const mutateVariables = Object.assign(
{},
variables,
mutateOptions.variables
);
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:14 (5 by maintainers)
Top Results From Across the Web
Mutations in Apollo Client - Apollo GraphQL Docs
variables. Any option you pass here overrides any existing value for that option that you passed to useMutation . The mutate function returns...
Read more >useMutation | TanStack Query Docs
The mutation function you can call with variables to trigger the mutation and optionally override options passed to useMutation . variables: TVariables.
Read more >Mutations - Client (React) - Apollo GraphQL Docs
This article also assumes that you've already set up Apollo Client and have ... In addition to a mutate function, the useMutation hook...
Read more >useMutation · Morrys Repositories
This package provides a useMutation Hook. ... function MyComponentWithHook({ myValue }) { const [mutate, { loading }] = useMutation( ...
Read more >Mutations with useMutation Apollo Client - React Tutorial 66
FREE React Course (download & bonus content) - https://calcur.tech/free-react-courseReact YouTube Playlist ...
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
This is a blocking issue for us to migrate to v3 currently. Thanks @amannn! Looking forward for https://github.com/apollographql/apollo-client/pull/6927 to be merged.
I’ve added a PR which should fix this 🙂
https://github.com/apollographql/apollo-client/pull/6927