T
tRPC

Global metadata / filters: Re-validate all queries

Global metadata / filters: Re-validate all queries

IItsWendell10/22/2023
Hi all, Simple question, I'm looking for the most efficient way to add some global state to all queries, in this case it's a global filter, for this use-case, let's call it testModeFilter. In our dashboard this could be a Context / Provider that manages this state, ideally, when testModeFilter, we want to: 1. invalidate all queries / refetch mounted queries 2. Make sure this global filter / metadata is passed to the server 'somehow' What's the best approach for this? E.g. I was thinking possibly a cookie, or a header but was wondering if there's other ways to sent global metadata with every query / mutation.
Nnlucas10/22/2023
headers are generally the best way for cross-cutting data to be sent to the backend. Beyond that it's probably an input key and some custom hooks which wrap up the tRPC hooks
IItsWendell10/25/2023
Was thinking about that, currently just giving it only to the queries that need it with a global recoil state, good enough for now but thanks, appreciate the response!

Looking for more? Join the community!

T
tRPC

Global metadata / filters: Re-validate all queries

Join Server