Describe the bug
When initializing queryClient with a custom hash function via defaultOptions.queries.querykeyHashFn, subsequent calls to queryClient.setQueryData do not use the custom hash function to generate a query hash. This results in a mismatch of query keys when attempting to consume the data.
To Reproduce
Steps to reproduce the behavior:
- Initialize a queryClient with a custom query hash function.
- Use
queryClient.setQueryData to insert a value for a given QueryKey
- Use
queryClient.fetchQuery or useQuery with the same query key and staleTime: Infinity (or any other value that should result in usage of the cached value without performing a fetch).
Expected behavior
The fetchQuery or useQuery calls should return the cached value, no fetch should occur.
Actual behavior
setQueryData does not use the custom hash function, resulting in a different query hash being generated. useQuery creates a second query object and issues a fetch/calls the queryFn.
Version
3.2.0-beta.29
Here's a Codesandbox demonstrating the issue
Describe the bug
When initializing
queryClientwith a custom hash function viadefaultOptions.queries.querykeyHashFn, subsequent calls toqueryClient.setQueryDatado not use the custom hash function to generate a query hash. This results in a mismatch of query keys when attempting to consume the data.To Reproduce
Steps to reproduce the behavior:
queryClient.setQueryDatato insert a value for a given QueryKeyqueryClient.fetchQueryoruseQuerywith the same query key andstaleTime: Infinity(or any other value that should result in usage of the cached value without performing a fetch).Expected behavior
The
fetchQueryoruseQuerycalls should return the cached value, no fetch should occur.Actual behavior
setQueryDatadoes not use the custom hash function, resulting in a different query hash being generated.useQuerycreates a second query object and issues a fetch/calls thequeryFn.Version
3.2.0-beta.29
Here's a Codesandbox demonstrating the issue