How do you invalidate a single page of useInfiniteQuery() and make sure only that page gets refetched ? #6691
-
I tried following approach with vue-query V5. But when I invalidate a specific page it refetches all pages that are visited.
Here, I just want to invalidate and refetch data of 5th page. Is there any way to achieve this ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
There is a |
Beta Was this translation helpful? Give feedback.
-
no, not possible anymore (we removed If you only refetch one page of the 5, and that yields new data, you will have duplicate or missing entries. The pages are a linked list where each one builds on top of the next. If you want separate cache entries for each page, you can do |
Beta Was this translation helpful? Give feedback.
-
@TkDodo that's not good |
Beta Was this translation helpful? Give feedback.
no, not possible anymore (we removed
refetchPage
) because it's not how infinite queries were intended to be used. They are one cache entry, chunked up into multiple fetches. That's why you can't pass something likequeryKey: ['data', 5]
. The key in the cache is justdata
.If you only refetch one page of the 5, and that yields new data, you will have duplicate or missing entries. The pages are a linked list where each one builds on top of the next.
If you want separate cache entries for each page, you can do
useQueries
and create an array with the length that you want, then concatenate the pa…