Closed codebycarlos closed 1 year ago
Also, thanks for this library, I think it's definitely a step in the right direction towards solving the mess that it can be managing queries and keys 🙂
Thanks for the great ideas @codebycarlos.
The suggestion is pretty good, but I need to sleep on the idea a little bit. It would be great to have all the query set up in there, but I'm not sure it introduces responsibilities beyond to what was intended for this lib.
If we get to the point of having all of this inside the lib, we might as well just return custom hooks? Feels like a natural path, but then there's already react-query-kit
as a solution for that...
+1
Stumbled across this lib recently and refactored one project to use it. I did define all my queries thinking this was possible:
export const getSomeQueryDefinition = (filters: BaseFilter = filter.base()) => ({
queryKey: [{ filters }] as const,
queryFn: () => fetchSomeData(filters),
options: {
enabled: !!filters.foo && someComplexCheck(filters.bar),
staleTime: 8000,
},
})
...
export const queries = createQueryKeyStore({
foo: {
myQuery: getSomeQueryDefinition,
}
})
anyways thanks for making this lib 👍🏻
What do you think about allowing all useQuery options, in order to allow more complex definitions?
For instance, if we wanted to always run this detail query with refetchOnMount set to 'always':
to
And so on..