How matchQuery work ?
I have a little problem with my query cache. I read this excellent article for good way to use react query : https://tkdodo.eu/blog/automatic-query-invalidation-after-mutations
Well Ive setup this client :
To be able to automatically invalidate some queries using
meta
. The problem rn is when invalidate this query key :
It invalidate also :
Just why ahah ? I was thinking React query invalidate sub query. Like when invalidate :
It can invalidate this ones :
thx for ur help !5 Replies
sensitive-blue•11mo ago
I think you want
matchQuery({ queryKey, exact: true }, query)
. The first parameter to matchQuery
is QueryFilters
: https://tanstack.com/query/latest/docs/framework/react/guides/filters#query-filtersTanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.

conscious-sapphire•11mo ago
your code should work - I do the same thing 🙂
would need to see a reproduction please
national-goldOP•11mo ago
Well yes its a pretty basic stuff I guess. What do u need as a reproduction ? (sry I dont really what can I give u my code is a garbage ahah)
Btw my keys are store like that for being sure having good key :
conscious-sapphire•11mo ago
Put the minimal thing to show the issue in a stackblitz
national-goldOP•11mo ago
That actually super weird, look at this mutation :
Here the part :
work as expected, it invalidate the right keys, but its the exact same code as the one in the React query provider :
To debug Ive made this :
And there is no
MATCH WITH
for the key : ["user","1234","playlists",{"order":"updated_at-desc"}]
so I guess the problem come from somewhere else
Well even doing this :
the query is revalidate that sooooo weird
IMMMMMM STTTUUUUPIIIIIIIIIDDDDDDD
DAAAAAAMNNNNNN
well mb im a shame for the world