trpc: feat: prefix infinite queries differently to "normal" queries?
Describe the feature you’d like to request
Currently, the cache gets a bit messed up if you use an endpoint the with .useInfiniteQuery() in one part of the app and .useQuery() in another.
Describe the solution you’d like to see
Currently, we store cache keys as [pathArray, input]-tuple
Maybe, we should store it as ['query' | 'infinite', pathArray, input]-tuple?
Or a [pathArray, 'query' | 'infinite', input]-tuple?
Desribe alternate solutions
Not doing it
Additional information
No response
👨👧👦 Contributing
- 🙋♂️ Yes, I’d be down to file a PR implementing this feature!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (10 by maintainers)
That’s exactly right. Objects have no order so the partial matching will work as you want to here. I’m going into details why the object is pretty good for query keys: https://tkdodo.eu/blog/leveraging-the-query-function-context
yes, those two would work.
I also thought about having one object, but I thought that we then wouldn’t be able to allow having
typeprovided from the params. Having theinputbe a separate entry in the object would solve that nicely I think 👍Can you use the same endpoint for normal and infinite queries? They do have different structures. They also definitely shouldn’t share the same query key…