refetchQueries with string arguments not updating component
See original GitHub issueIntended outcome: Given a query:
const AllUsersQuery = gql`
query AllUsers {
users {
id
login
}
}
`;
Using refetchQueries: ["AllUsers"]
in a mutation should re-execute the query and update any components depending on that query.
Actual outcome: While the query is re-executed, the component never updates. Using the apollo dev tools in Chrome, I can see the new User item listed in the store, but it never makes it to my component.
If I instead import the original query variable and use refetchQueries: [{query: AllUsersQuery}]
, everything works as expected.
How to reproduce the issue:
Use string arguments in refetchQueries
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Refetching queries in Apollo Client - Apollo GraphQL Docs
refetchQueries method collects the TResult results returned by onQueryUpdated , defaulting to TResult = Promise<ApolloQueryResult<any>> if onQueryUpdated is not ...
Read more >RefetchQueries does not correctly update the store
If I check the network tab, the datas are correctly refetched and updated but the component doesn't receive the updated datas.
Read more >Advanced topics on caching - Client (React)
A very common way of using refetchQueries is to import queries defined for other components to make sure that those components will be...
Read more >Async data made simple with React Query - Hey! I'm Tyler
The first parameter to useQuery is a string and this is how the hook knows ... Also, if you are working with axios,...
Read more >Components: apollo-mutation - Apollo Elements
Do more with less code with Apollo Elements and web components. ... boolean. If true, the returned data property will not update with...
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
I’m seeing the same behaviour @jpikora, passing the query document works but passing the operation name as a Array<string> doesn’t update the cache.
@jpikora I still believe that this is the race condition outlined in #1821