Replies: 2 comments 7 replies
-
I'm pretty sure you still want |
Beta Was this translation helpful? Give feedback.
-
The primary speciality is the integration of WebSockets. I don't want to constantly query the fetchTodos endpoint, as the WebSocket ensures that new data is automatically pushed to the client. To accomplish this, I use setQueryData(["todos", "todoKey"], data) to populate individual elements into the cache. Consider a scenario with hundreds of todo's, which are frequently updated by you or other users. Continuously refetching these to-dos with each mutation would significantly impact billing and is not very efficient, especially for users with poor network connectivity. For this reason, I initially use fetchTodos to obtain the items and populate the cache. Subsequently, I retrieve all updates through the WebSocket. Thats why it would be handy to have some functionality to query the elements in the cache. Something like this would be handy. useQueryCache({
filter: ["todos"],
exact: false,
predicate: (query) => query.queryKey[0] === "todos" && !!query.queryKey[1])
}) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Imagine the following use-case:
setQueryData(["todos", "todoKey"], data)
setQueryData(["todos", "todoKey"], data)
Now I am a bit stucked on how to query those todos. For now I use the following, but it seems a bit unhandy? Is there another way or am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions