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.

query gets replaced in the cache when calling the same query with different args

See original GitHub issue

Intended outcome:

I want to refetch a query that has been called multiple times but with different variables after a mutation So basically, I have a page where I query a list of items with some variables. Then I go to a different page and now I use the same query but with different variables.

Actual outcome: When I go to the apollo devtools, I can see both queries there, but the first one gets replaced with the most recent one. So later on, when I use a mutation and I try to refetch the query by it’s name, it refetches only the most recent one

I can’t use the refetchQuery with the variables since at the moment I do the refetch, I don’t have the original arguments that the query was called

Versions

System:
    OS: macOS 10.15.7
  Binaries:
    Node: 14.9.0 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.7 - /usr/local/bin/npm
  Browsers:
    Chrome: 86.0.4240.183
    Safari: 14.0
  npmPackages:
    @apollo/client: 3.2.5 => 3.2.5 
    @apollo/link-context: ^2.0.0-beta.3 => 2.0.0-beta.3 
    @apollo/link-error: ^2.0.0-beta.3 => 2.0.0-beta.3 
    apollo-upload-client: ^14.1.2 => 14.1.2 
  npmGlobalPackages:
    apollo-codegen: 0.20.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hwillsoncommented, May 15, 2021

@tafelito any chance you can put together a small runnable reproduction that shows the issue?

1reaction
tafelitocommented, May 15, 2021

@hwillson As far as I know, keyargs won’t help in this case

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customizing the behavior of cached fields - Apollo GraphQL
In the query response, the field is populated with the read function's return ... The first parameter is the field's currently cached value...
Read more >
How to handle Apollo cache updates for queries with multiple ...
I have a getTracks query that will fetch track data, and takes a handful of arguments for sorting/filtering (limit, offset, search, sort, order) ......
Read more >
Redux Essentials, Part 8: RTK Query Advanced Patterns
So, RTK Query canceled the timer and kept using the same cached data ... into another file to keep the API slice file...
Read more >
Customizing the behavior of cached fields - Client (React)
If you define a read function for a field, the cache calls that function whenever your client queries for the field. In the...
Read more >
@urql/exchange-graphcache | urql Documentation
As a second argument the method accepts an updater function. This function will be called with the query data that is already in...
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