You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have to integrate some apis that return nd-json and take a few seconds to complete the response. I'd like to stream the response so users see at least some data quickly. To do this with tanstack query I'm using the following.
constqueryFn=useStreamingQueryFn(asyncfunction*({ signal }){constres=awaitfetch("/api/ndjson",{ signal });yield*ndJson(res.body)})constqueryResult=useQuery({queryKey: ["some","key"],
queryFn
})
This all works, but calling setQueryData sets the query status to success. That's reasonable default behavior but I'd like an option to set the data without updating the status so I can keep displaying a loading indicator until everything has loaded.
Feature Request
Add an option to queryClient.setQueryData to not update query state along with the data
Add queryClient to QueryFnContext so the streaming query function doesn't need to be a hook
Alternatively, add a setQueryData function to QueryFnContext, possibly one with the queryKey already set
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have to integrate some apis that return nd-json and take a few seconds to complete the response. I'd like to stream the response so users see at least some data quickly. To do this with tanstack query I'm using the following.
Then in the component I have
This all works, but calling
setQueryData
sets the query status tosuccess
. That's reasonable default behavior but I'd like an option to set the data without updating the status so I can keep displaying a loading indicator until everything has loaded.Feature Request
queryClient.setQueryData
to not update query state along with the dataqueryClient
toQueryFnContext
so the streaming query function doesn't need to be a hooksetQueryData
function toQueryFnContext
, possibly one with thequeryKey
already setOlder discussion
Beta Was this translation helpful? Give feedback.
All reactions