PersistQueryClient

Hi! I would like to try using https://tanstack.com/query/v4/docs/react/plugins/persistQueryClient with my Refine project and was wondering if I could get help with this. I tried wrapping the app with PersistQueryClientProvider but have had no luck. Thanks!
persistQueryClient | TanStack Query Docs
This is set of utilities for interacting with "persisters" which save your queryClient for later use. Different persisters can be used to store your client and cache to many different storage layers. Build Persisters
7 Replies
eastern-cyan
eastern-cyan2y ago
Hey @misstsuliu As far as I know refine has no such support. However, lets meet with core team and report the result.
Omer
Omer2y ago
Hey @misstsuliu 👋, What kind of case do you want to use persistQuery? Can you share a use case? ⚡️
optimistic-gold
optimistic-gold2y ago
Hi there! I am interested to use this so that cached queries persist after a page reload in local storage, as react-query currently stores cache in memory 🙂
Omer
Omer2y ago
Hey again @misstsuliu 👋 , We have discussed this issue with the core team and we are unable to do so with refine@3. But the good news is we're working on refine@4 and we think we can support it there 🍻
optimistic-gold
optimistic-gold2y ago
Hey, thanks Omer! Out of curiosity, when you say it'd be something v4 can support, do you mean that it'd be built-in? If not, can you elaborate? Appreciate the help 🙂
Omer
Omer2y ago
Actually the problem is that you can't override this line https://github.com/refinedev/refine/blob/next/packages/core/src/components/containers/refine/index.tsx#L345 We will give the user a way to do this with refine@4 🚀 Hey @misstsuliu , I have a piece of great news 🥁 @aliemirs mentioned that we can use persist-query. We tried it and it really worked. I created an example for you https://github.com/refinedev/refine/pull/3423/files#diff-7f8c9bef872ccf68780d05abc3449022047e2fd81ab8f48e22fb81e4eb412842R6 live example: https://refine.dev/docs/examples/persistQuery/
optimistic-gold
optimistic-gold2y ago
Thank you!!