-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
querykeys not being fuzzy matched #5111
Comments
query/packages/query-core/src/queryCache.ts Lines 179 to 181 in d2af584
General rule of thumb:
The reason is quite simple: What would
if we match this fuzzily, it would be non-deterministic which one would be returned. Probably the one that was first inserted, but it's an implementation detail. I'm not sure what the use-case of yours is, but you can:
|
Alright thanks for the response! Closed our issue too :) |
Do you have a section in the docs explaining when you do fuzzy matching? Was going to make a note in our docs about this behavior |
Do you have a section in the docs explaining when you do fuzzy matching? Was going to make a note in our docs about this behavior hmm, no 🙈 . Filters are fuzzy unless you specify
If you want, you can add it to the |
Describe the bug
When filtering queries using
getQueryData
, it seems like the queryKey isn't being fuzzy matched. In tRPC, we have queryKeys like[["post", "all"], { input: { id: 1 } }]
, and so we should be able to match this by looking for just[["post", "all"]]
, but that doesn't seem to be the case.This is the original issue we got: trpc/trpc#3937
Your minimal, reproducible example
https://stackblitz.com/edit/github-kuehgz-xevj3b?file=package.json
Steps to reproduce
See stackblitz. The only way you seem to get the data is by looking for the key exactly.
Expected behavior
const getQueryData = queryClient.getQueryData(lazyKey);
should return"hello"
, notundefined
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
macOS, Arc
Tanstack Query adapter
react-query
TanStack Query version
4.26.1
TypeScript version
4.8.3
Additional context
No response
The text was updated successfully, but these errors were encountered: