Can I normalize every queryKey globally?
I have an issue where queryKey is used inconsistently across the project—it can be an object, an array, etc. To standardize it, I created a function normalizeQueryKey that sorts each key and converts it into a string.
For example:
Now, I manually normalize every queryKey.
My question is: Can I normalize every queryKey globally?
I tried using queryKeyHashFn, but I noticed that queryKey remains unchanged—it only formats queryHash. As a result, if queryKey is different, TanStack Query still triggers a refetch.
So, is there a way to normalize every queryKey globally?
For example:
Now, I manually normalize every queryKey.
I tried using queryKeyHashFn, but I noticed that queryKey remains unchanged—it only formats queryHash. As a result, if queryKey is different, TanStack Query still triggers a refetch.
So, is there a way to normalize every queryKey globally?