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.

refetchQueries with string arguments not updating component

See original GitHub issue

Intended 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
craigmulligancommented, Mar 26, 2018

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.

2reactions
ctavancommented, Jan 29, 2018

@jpikora I still believe that this is the race condition outlined in #1821

Read more comments on GitHub >

github_iconTop 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 >

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