-
Hi @TkDodo react-query 3.6.0 Currently in my app, i need to feature toggle between API and graphQL depending on feature flag value in the app My API and GraphQL functions are dependency-injected via RepositoryProvider, useQuery seems to only update if the queryKeys update (regardless if the queryFn passed is updated) but my case, when i passed repository Object into queryKeys array, it recognized as {} , so toggling between API and GraphQL won't trigger useQuery update, do you have advice on this? Sandbox Reproduction: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
sorry, I won't be looking into v3 because it's very old, but what I can say is that everything in the queryKey has to be json serializable. If you put something in there that's not, it won't work unless you provide your own As far as I can see, you try to put a function into the query key, and that certainly won't work. |
Beta Was this translation helpful? Give feedback.
the issue is the same in all versions: the key is not serializable. don't put functions in the key, and if you must, provide a
queryKeyHashFn
that can serialize it to something unique.