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?2 Replies
deep-jade•3y ago
Why do you need an interval if youre getting data every 100ms anyways?
You can pass dataUpdatedAt to setQueryData
other-emeraldOP•3y ago
I don't get all the data from the websocket. For example, this is what
queryFn returns:
The websocket only updates websocketData:
I need to re-fetch the query based on refetchInterval to sync queryData with the server. That's why I need both.
I also tried using updatedAt but it didn't work. This is how I used it: