Global metadata / filters: Re-validate all queries
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.2 Replies
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
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!