simonsimcity
simonsimcity2w ago

Query invalidation per mutation-key

I just learned about query invalidation using the classic implementation, and that it provides an option to invalidate all queries on every mutation (https://trpc.io/docs/client/react/useUtils#invalidate-full-cache-on-every-mutation). I haven't followed up on the possibilities the new TanStack React Query provides, but I was just about asking whether it's possible to also get the key of the mutation in the general function. I would like to have some central place, where I register that every mutation on key X should invalidate query Y and Z. I would like to skip having to remember this every time I write a mutation, but I still want to be more specific that just reloading everything on a mutation. Hope my request is understandable 😅 I'm myself just getting warm with this lib, but I like it a lot already ♥️
useUtils | tRPC
useUtils is a hook that gives you access to helpers that let you manage the cached data of the queries you execute via @trpc/react-query. These helpers are actually thin wrappers around @tanstack/react-query's queryClient methods. If you want more in-depth information about options and usage patterns for useContext helpers than what we provide h...
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?