TanStackT
TanStack3y ago
3 replies
foolish-indigo

How to update query data without resetting refetchInterval timer?

I have a query that should be re-fetched every X seconds. The solution is to use refetchInterval. But I noticed that calling setQueryData resets the refetchInterval timer.

In my case, I have a websocket connection that updates part of a query data every 100 milliseconds (with setQueryData). If the refetchIntervalis larger than 100ms, the queryFn will never re-run. But I want the queryFn to re-run because the websocket only updates part of the query data and I want to keep the rest of it in sync with the server using refetchInterval. Our API socks and this is probably an edge case, but I have no choice but dealing with it. Is there a solution?
Was this page helpful?