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.

[3.0 Beta 41] Evict API does not support eviction based on arguments

See original GitHub issue

Hello! I am playing around with the 3.0 eviction API. I see that we can evict by dataId and fieldName. If I make two queries for a user’s total balance for their currencies, they get stored in the cache under the ROOT_QUERY like this:

totalBalance({ currency: 'USD' }) totalBalance({ currency: 'CAD' })

If they they added a new USD account, I want to invalidate their USD total balance by doing:

cache.evict('ROOT_QUERY', 'totalBalance({ currency: "USD" })')

But that isn’t a valid field name, instead I need to do:

cache.evict('ROOT_QUERY', 'totalBalance') But that invalidates both my cached queries. I would think that there should be a way to invalidate queries based on their arguments, since in some applications there may be many of the same query type made with different filters etc and that users can perform actions to invalidate subsets of these.

The issue is here: https://github.com/apollographql/apollo-client/blob/master/src/cache/inmemory/entityStore.ts#L130

it checks for modifiers based on the fieldName not the storeFieldName. It would be great if it could first check modifiers for the storeFieldName too, and have that modifier take precedence over the fieldName modifier. Thoughts?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
benjamncommented, Apr 3, 2020

Are you comfortable with having to pass exactly the same arguments that were originally used to store the field in the cache? The only reason I ask: I don’t think we can reasonably match subsets of fields if you pass some but not all of the original arguments.

Of course, passing only an ID and a field name will continue to evict all variations of the field, regardless of arguments.

If that feels right, then I think we could extend the API with another argument:

cache.evict("ROOT_QUERY", "totalBalance", { currency: "USD" })

If I recall correctly, the reason I didn’t add arguments to the cache.evict API originally was that the EntityCache did not have easy access to the Policies object, but that changed with commit 9dcc33c9c366412b9ac50ed0c0b373a88145a32b.

2reactions
benjamncommented, Jul 10, 2020

Since we now support evicting by specific arguments (see #6141 and #6364), I think this issue can be closed. Still, I like your idea of an eviction predicate function @Vincz. Can you open a separate feature request for that? Feel free to refer back to this discussion for background/context.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API-initiated Eviction - Kubernetes
API -initiated eviction is the process by which you use the Eviction API to create an Eviction object that triggers graceful pod termination....
Read more >
§ 42–3505.01. Evictions. | D.C. Law Library
(a)(1) Except as provided in this section, no tenant shall be evicted from a rental unit, notwithstanding the expiration of the tenant's lease...
Read more >
Discrimination in Evictions: Empirical Evidence and Legal ...
This Article is among the first to empiri- cally investigate racial and ethnic discrimination in eviction decisions. It does so by drawing on...
Read more >
LANDLORD/TENANT BASICS - California Courts
(If the tenant does not respond to the 3/30/60/90 day notice, you may ... The landlord is trying to evict you based on...
Read more >
Tenants & Landlords - Michigan Legislature
it is not a substitute for the services of an attorney and ... Q9 Can the tenant be evicted and still forced to...
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