New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: (customizable) query key prefix #5251
Comments
I also have the same question how to specify a query key in each query |
I need to specify a custom query key and I'm unable to. This means I can't use TanStack Query's hierarchical invalidations. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: