Giter VIP home page Giter VIP logo

Comments (7)

jerelmiller avatar jerelmiller commented on May 23, 2024 1

@ismailassa thank you! This is useful. Appreciate it!

from apollo-client.

ismailassa avatar ismailassa commented on May 23, 2024 1

@ismailassa thank you! This is useful. Appreciate it!

Never mind, resetStore() resets the cache in the new version

from apollo-client.

jerelmiller avatar jerelmiller commented on May 23, 2024

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.

keeganstothert avatar keeganstothert commented on May 23, 2024

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.

jerelmiller avatar jerelmiller commented on May 23, 2024

Thanks! A reproduction would be super helpful.

from apollo-client.

kainosnoema avatar kainosnoema commented on May 23, 2024

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.

ismailassa avatar ismailassa commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.