First of all, I'd like to say I really really like the upcoming changes in @next, especially the cache object. Awesome job!
However, there is one thing I cannot wrap my head arround why it's going to change.
It seems that when you are passing variables along with the queryKey (f.e. useQuery(['user', id], handler) the string 'user' is going to be the first argument of 'handler'.
I know the docs and changelog in @next are saying that this has changed but do we really want this to be our next default?
It means that all handlers now most likely become an ugly handler(_: string, ....). It feels to me that the handlers now have to be tweaked in order to satisfy react-query rather then them being standalone APIs (which wouldnt have a random string as first argument).
Am I the only one against this API change? What was the use-case that this API had to change?
Some users, regardless of suggestion or encouragement, choose to use URL's as their query keys or choose to pass a generic query function for their entire app. This allows them to forgo their hacks and have first-class support for their use case.
I agree that it's not entirely backwards compatible, but I'm working up some solutions so that it can be on a per-app basis.
You can now use the global/useQuery config option queryFnParamsFilter to give yourself backwards compatibility like so:
useQuery(['todo', id], id => fetchTodoById(id), {
queryFnParamsFilter: args => args.slice(1),
})
Most helpful comment
You can now use the global/useQuery config option
queryFnParamsFilterto give yourself backwards compatibility like so: