Comments (7)
@ismailassa thank you! This is useful. Appreciate it!
from apollo-client.
@ismailassa thank you! This is useful. Appreciate it!
Never mind, resetStore()
resets the cache in the new version
from apollo-client.
Hey @keeganstothert 👋
Are you referring specifically to the return value of the hooks or the cache itself? This statement makes me think you're referring to the cache itself, but I'm not so sure:
here is absolutely no way to clear, reset, or evict the cache using this library.
I've tried reproducing this behavior and I'm seeing the cache clear just fine. Here is an example that calls clearStore
on a button click. If you look at the console logs, you'll see there is cache data before the clearStore
call, but its empty after calling that function: https://codesandbox.io/p/devbox/priceless-firefly-2vjsnk
If you're not seeing this behavior, a reproduction would be super helpful. The docs link as the reproduction URL doesn't help us much 😆
from apollo-client.
I believe there are 2 things happening in my case that could be the issue.
My extensive use of the previousData
field and my expectation that the cache actually gets deleted rather than simply forcing old queries to fire again.
when I call client.resetStore()
this seems to do nothing but re fire queries. it doesn't actually reset (empty) the cache. and client.clearStore()
simply has no effect, and the same goes for the other methods like evicting.
in a react app my goal is to navigate to a page which uses something like
const { data, previousData, loading } - useQuery(USER_MANY)
const users = (data ?? previousData)?.userMany?.payload;
and have it load as if it were the very first time. However it ALWAYS presents cached data if that query has run previously.
i'll whip up a codesandbox shortly.
from apollo-client.
Thanks! A reproduction would be super helpful.
from apollo-client.
We've also been seeing this for awhile. Ended up just reloading the window after sign out because there doesn't seem to be a way to actually reset the Apollo cache/store.
from apollo-client.
Hi @jerelmiller!
I noticed a difference in behaviour between apolloclient 3.4.0 and 3.9.6 (I've created a codesandbox for both versions to demonstrate the difference in behaviour).
In version 3.4.0, when you use a local query for writing to the cache, all the useQueries reading this local query get notified about the update and re-renders , check: https://codesandbox.io/p/devbox/apollo3-4-0-react17-3dt9l6?file=%2Fsrc%2FApp.jsx%3A47%2C26
This isn't happening in the new version of apollo/client, the cache gets updated but the read queries don't get notified about the update: https://codesandbox.io/p/devbox/mnjtr3?file=%2Fsrc%2FApp.jsx%3A14%2C10
from apollo-client.
Related Issues (20)
- [Data masking] Add `@unmasked` directive that makes all data available in the query
- [Data masking] Warn when accessing masked fields with `@unmasked` queries
- [Data masking] Allow parent object in query to be passed to `from` option in `useFragment`
- [Data masking] Provide codemod to add `@unmased` directives to all queries
- [Data masking] Create ESLint plugin/rule that detects usage of `@unmasked` directives
- [Data masking] Allow `useFragment` to work with `no-cache` queries
- [Data masking] Suspend `useFragment` when a deferred fragment is pending
- [Data masking] Conditionally suspend `useFragment` depending on source of query
- [Data masking] Conditionally suspend `useFragment` depending on `fetchPolicy` and cache availability
- default errorPolicy : "all" HOT 4
- [Data masking] Create data masking guide in documentation
- [Data masking] Provide guide on migrating from data masking in GraphQL Codegen
- [Data masking] Create guide on integrating data masking with GraphQL Codegen
- `useQuery` API documentation anchor links are all `#undefined` HOT 3
- `useFragment`, returns false data. HOT 6
- useFragment accepts a generic type, but it converts it into a DeepPartialObject. what is the best usage in here to avoid using DeepPartialObject? HOT 4
- Pagination using useSuspenseQuery gets empty array instead of cached array when api response with empty array HOT 4
- Merging array in DeepMerger HOT 3
- RFC: Schema-driven testing HOT 2
- Infer `connectToDevTools` regardless of whether another client has connected or not
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-client.