-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Describe the bug
Hello, currently I'm using TSQuery with an async IndexedDB persister, for > a year now, everything works good, but I'm encountering an issue where it seems like there is no way for me to force a refetch/invalidate/clear for the cache before it is used for the first time / loaded-in from the store.
Use case: I have a query that can be served from cache for some pages, but for a specific page, I want it to always do a refetch on mount to ensure latest data, here is where the problem starts, if I have not previously loaded the queryKey (e.g.: doing a page refresh), there seems to be no solution that works to efficiently force a refetch for said queryKey.
I have tried all combinations of doing refetch(), invalidateQueries, cancelQueries before and after the useQuery is called, but none of it is able to tell Tanstack Query to skip loading the data from the persist store and do an API fetch directly, TanStack Query will keep on going to fetching status but to load the data from the store, not the API and does not even try to do a new request after that, even this does not work:
invalidateQueries()
const { refetch } = useQuery() // fetchStatus = 'fetching', trying to load from persister store
cancelQueries() // fetchStatus = 'idle'
refetch(); refetch(); // fetchStatus = 'fetching', but still to load from store, not API request, even when called two times (without await of course, just trying to make it bypass the store load and do one fetch, not wait for load and do multiple fetches.)
Your minimal, reproducible example
TBA
Steps to reproduce
TBA
Expected behavior
TBA
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
TBA
Tanstack Query adapter
vue-query
TanStack Query version
"@tanstack/query-persist-client-core": "^5.91.4", "@tanstack/vue-query": "^5.90.5"
TypeScript version
^5.9.3
Additional context
No response