Mutation refetchQueries has only effect if useQuery is rendered at the same time
See original GitHub issueHeyo, I’ve created a CodeSandbox to showcase this:
In this example, if you click on “both”, put something in the form and submit it, the list updates instantly. (As I would expect it to)
But if you click on the “form”-Button, so only the form, but not the list is rendered, then fill & submit the form and then go back to the “list” view, the list is still in the old state, which means the getList query seems not to have updated.
Funny enough, when using the evaluated graphql (passing the GET_LIST constant) instead of the string getList, it seems to update. But in that case, I have to provide all variables - and if the form does not know, which variables are used in a query in a different component, that means it is impossible to trigger the query from the form.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)

Top Related StackOverflow Question
Seriously? This has three views, because two views are required to show off the bug and one is required to show that there are conditions the bug does not happen. It consists of two components (that could be straight out of the readme of this lib), a query, a mutation and one “App” to switch between the views.
What do you want to simplify there?
Just ran into this same issue. Switched from using
useMutationanduseQueryto the<Mutation />and<Query />and it solved the problem, so I think @phryneas is correct that either the issue lies within react-apollo-hooks, or else react-apollo is doing its own work to paper over the issue in apollo-client.