Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refetchQueries with string arguments not updating component #1561

Closed
dmarkow opened this issue Apr 7, 2017 · 11 comments
Closed

refetchQueries with string arguments not updating component #1561

dmarkow opened this issue Apr 7, 2017 · 11 comments

Comments

@dmarkow
Copy link
Contributor

dmarkow commented Apr 7, 2017

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

@saudpunjwani101
Copy link

refetchQueries takes a query object, I don't think u can actually pass a string to it.

@dmarkow
Copy link
Contributor Author

dmarkow commented Apr 9, 2017

@saudpunjwani101 The documentation on refetchQueries says it can take an array of either strings or objects (and the first example uses the string option).

@saudpunjwani101
Copy link

Yeah ur right, although the query does re execute it's not resolving the updates. I'll try it

@helfer
Copy link
Contributor

helfer commented May 3, 2017

@dmarkow could you provide a reproduction for this?

@MichaelDeBoey
Copy link
Contributor

MichaelDeBoey commented May 6, 2017

@dmarkow If your get back a union, then this could be the same problem as in #1611, which is 'fixed' (you'll get warnings what to do) by #1638 :-)

@dmarkow
Copy link
Contributor Author

dmarkow commented May 6, 2017

I just tried to reproduce this on the current version and can't, so maybe it was resolved with some of the recent updates... Thanks!

@dmarkow dmarkow closed this as completed May 6, 2017
@ctavan
Copy link

ctavan commented Jun 23, 2017

Might be related to the race-condition described in #1821.

@jpikora
Copy link
Contributor

jpikora commented Jan 27, 2018

I've just come across the same issue as @dmarkow.

Object format [{ query: ... }, ...] for refetchQueries is working correctly, but when using Strings ['queryName', ...] the store is not updated, even though the refetch requests are correctly executed.

[email protected]

@ctavan
Copy link

ctavan commented Jan 29, 2018

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

@craigmulligan
Copy link

I'm seeing the same behaviour @jpikora, passing the query document works but passing the operation name as a Array doesn't update the cache.

@jcace
Copy link

jcace commented Jan 24, 2020

Any update on this? I still can't pass string arguments to refetchQueries, as they don't seem to update the cache. Apollo client v2.6.8

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants