Replies: 2 comments
-
The |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hope this is the correct place for this! But have been using and loving Tanstack Query lately, it's made things a lot easier to work with!
I have a question: is there a way to have a query parameter on the first request of a useQuery, and then "remove it" (and cache an object returned in that result) for future requests?
For example, I want to make this useQuery call with the parameter for the first time only (I only want to do it once because this parameter adds onto load times, but provides more up-to-date data than without the parameter - which could then be used in future requests)
http://api.example.com/roles/?sync_users=True
Somewhere in the data returned will be a
users
object, which contains up-to-date information. I want to keep a hold of this over future requests, and for it to take precedent over otherusers
objects that will be returned in future requests.So in further requests (because that call has been done once at the start), remove that parameter to speed things up again, to be like I was calling
http://api.example.com/roles/
. This will return ausers
object, but not the one we want - which is the data wanted from the initial requestIs this where something like initial query data would come into play?
Would I need to somehow merge the
users
object data in the latest request, with the previous cached request results?I hope this makes a smidge of sense to someone! 😅
Beta Was this translation helpful? Give feedback.
All reactions