question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mutation refetchQueries logic is missing

See original GitHub issue

The logic found here is missing from useMutation which is causing refetchQueries in the shape of refetchQueries: ['nameOfQuery'] to fail.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Negan1911commented, Jun 10, 2019

Thanks for the example, either way I wouldn’t want to actually break my head as you did for trying to refetch a simple list, I would love to check with @trojanowski that this isn’t an edge case, is the only way to refetch queries in a simple manner, and if he agrees, i can even actually try to help with a PR.

3reactions
Negan1911commented, Jun 10, 2019

I don’t think that this is an edge case, also, I can’t find where is said that is going to be deprecated (it is for 3.X but we’re still on Apollo 2 and there’s no other way around this), actually passing refetchQueries as an array of string is the only way to refetch the previous query with the same parameters previous variables, using refetchQueries: { query: MY_QUERY } sends and {} as variables so I can’t refetch it properly.

EDIT: Actually, is stated as the only proper way to refetch with previous variables

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refetching queries in Apollo Client
To selectively refetch queries outside of a mutation, you instead use the refetchQueries method of ApolloClient , which is documented here. client.
Read more >
reactjs - RefetchQueries does not invalidate cached data ...
In some cases I am using refetchQueries to make sure cache is invalidated when a mutation is done. This does work as expected, ......
Read more >
Advanced Topics on Caching – Angular
apollo.mutate({ // ... insert comment mutation refetchQueries: ... Apollo Client will fire the fetchMore query and use the logic in the ...
Read more >
Apollo Client Caching
For mutations that update an existing object, this linking mechanism makes most ... Specify the queries to reload with refetchQueries .
Read more >
@apollo/client | Yarn - Package Manager
Apollo Client is a fully-featured caching GraphQL client with integrations for React, Angular, and more. It allows you to easily build UI components...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found