Replies: 1 comment 1 reply
-
active queries will be refetched, inactive ones will be marked as stale.
Only if the query is actively used. I guess if you have I would usually just let the Query sit in the cache and let it be garbage collected after cacheTime has ellapased. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi folks,
I have encountered the following problem. First of all let's see if I got all the facts right. Since the documentation on removeQueries is kind of lacking. When we invalidate queries the queries that are cached will be marked as stale and will be prefetched, right? So when we useMutations to delete something from the database that we previously got via useQuery with some queryKey without removal of that query from the query cache it will query the backend and I will get 400 error. Did I get this part right?
Assuming that I did. On my project, I am dealing with tree-like structures that contain multiple workspaces that contain multiple X that may or may not contain multiple Y.
Deletion of the project on the backend is done recursively as it should, but every entity (project, workspace, X,Y) I have in my query cache, so when I delete the project I assume that I should also remove queries for the given entities because if I don't it will throw me an error when I invalidate Queries on success function of the delete mutation.
And that works like in 7/10 times. The majority of times the cache is removed, and the invalidate query will not cause the refetch of something that is deleted on the DB, but sometimes it does.
Did I totally misunderstand the concept of remove/invalidate Queries and onSucess functions in useMutation hook?
And if someone has some insights I am glad to hear it.
Tnx
Beta Was this translation helpful? Give feedback.
All reactions