You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like trpc query keys to have some prefix (e.g. 'trpc') to make it easy to identify them when setting up a QueryClient. This is useful when the query client is not only used for trpc. A simple example:
Currently, getQueryKey(trpc) simply returns [], meaning that any mutation would invalidate all react-query queries, not only trpc queries. Being able to specify a prefix (or just having a prefix in general) would make it return [prefix], making it possible to distinguish between trpc queries and other queries.
I'm sure there are other (perhaps more useful) use cases than this
Describe the solution you'd like to see
Either a built in trpc prefix for all query keys, or a way to specify a prefix
Describe alternate solutions
I think the only real solution at the moment is to manually pass a react query context to trpc, such that you have an isolated query client (haven't tested this, seems like a reasonable idea)
Alternatively you could also create a wrapper route that serves as the root route to make sure that the query key is not empty
Additional information
If this is something that would be merged I am willing to give implementing this a shot
👨👧👦 Contributing
🙋♂️ Yes, I'd be down to file a PR implementing this feature!
Funding
You can sponsor this specific effort via a Polar.sh pledge below
We receive the pledge once the issue is completed & verified
The text was updated successfully, but these errors were encountered:
Describe the feature you'd like to request
I would like trpc query keys to have some prefix (e.g. 'trpc') to make it easy to identify them when setting up a QueryClient. This is useful when the query client is not only used for trpc. A simple example:
Currently,
getQueryKey(trpc)
simply returns[]
, meaning that any mutation would invalidate all react-query queries, not only trpc queries. Being able to specify a prefix (or just having a prefix in general) would make it return[prefix]
, making it possible to distinguish between trpc queries and other queries.I'm sure there are other (perhaps more useful) use cases than this
Describe the solution you'd like to see
Either a built in
trpc
prefix for all query keys, or a way to specify a prefixDescribe alternate solutions
I think the only real solution at the moment is to manually pass a react query context to trpc, such that you have an isolated query client (haven't tested this, seems like a reasonable idea)
Alternatively you could also create a wrapper route that serves as the root route to make sure that the query key is not empty
Additional information
If this is something that would be merged I am willing to give implementing this a shot
👨👧👦 Contributing
Funding
The text was updated successfully, but these errors were encountered: