How to invalidate tag for a endpoint with a certain parameter header? #3731
Unanswered
nihalshetty0
asked this question in
Q&A
Replies: 0 comments
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.
-
I am using RTK query for my application. My application has infinite scroll and I am using something like this to concat newer page with older pages.
Just for reference, I am receiving the data from the API, as such:
Since, I am doing this, on patch of an item from this list, I can't just invalidate the getJobs endpoint, as it would remove all the page but page 1 from UI.
Therefore, I am handling the item update as such:
The above code works perfectly well
Now, this issue is, let's say I have not added any filter, and the endpoint is
/jobs?page=1and later, I add a filter like/jobs?page=1&skill=123. Now both endpoint are cached. If, I were to make any changes in item, when user is on/jobs?page=1and that item also happens to exist on/jobs?page=1&skill=123, then this item will only update/jobs?page=1cache and not in/jobs?page=1&skill=123cache.I cannot invalidate the
getJobsendpoint because the jobs list and patch jobs item are on the same page. If I were to invalidate it, then the list would refresh, every time a job item is changed and the scroll would jump up.Solution I can think of is to:
/jobs?page=1. Need to also, do this for/jobs?page=1&skill=123as wellI want to know how we can do the above, in RTK. Any of the two method is fine.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions