How to handle when query depends on a non string/JSON serializable object reference?
I am not fetching any API external data, I am using React Query as an async state manager in one of my projects.
A specific query depends on many other object references to be transformed and be available in the shape I want.
These other object are very large, and some of them are not JSON serializable.
I would like a query key that doesnt parse all its content to string, but instead use the object reference as the comparing subject.
Since the query key relies on string serializable variables, I hashed the references. I put together something like this.
It got better to read in the query devtools aswell.
2 Replies
continuing-cyan•8mo ago
You can provide your own
queryKeyHashFn
, and you can set it as a default option for all queriesequal-aquaOP•8mo ago
Helpful, Thank you!