Closed lauri865 closed 2 months ago
I also have a use case where this should be allowed: head: true
queries with count
. I did not touch the code base for a while so it will take a while for me to go that deep again and figure out how we can allow wildcards.
Tried to understand the code flow, and this is what I pictured together:
A few problems:
Some thoughts:
Probably a lot I didn't understand in the code base. Wondering now if a fresh stab at this with a simpler model would make more sense at this point for us. As a developer, I want to achieve base case automated cache invalidation first, and then make things progressively better.
I need the * selector also
Same
temporary fix:
export const queryFields = <T extends object>(): string => {
return (Object.keys({} as { [K in keyof T]: T[K] })).join(',');
};
There's benefits to using useQuery without granular updates from mutations (e.g. auto-serialized queryKeys for filtering, etc.).
I believe thus by making the no wildcard rule less strict, we could make the library more useful.
I would be fine if e.g. all wildcard queries would get invalidated upon a mutation to the underlying table or any relation.
Not using wildcard would just make mutations more granular. But it doesn't have to be so binary, does it? (lmk if I'm missing something)
A console.warn in development would be enough to inform the devs about wildcard use, but no need to throw errors.
(Talking from react-query perspective, not sure about SWC considerations)