Skipping queries with top-level skipToken
Is there a reason for not supporting a top-level skipToken? I.e.
useQuery(skipToken).
This would improve ergonomics when working with the queryOptions API. E.g. I'm currently facing this:
This obviously does not work, but to make it work I would need to make getCustomerQueryOptions aware of the possibility the query may be skipped, but I don't think that should be part of the query options definition as it can lead to broader types. Broader types would for instance cascade to my query key factories.
Would love to hear all of your thoughts about this1 Reply
adverse-sapphire•8mo ago
It's not really possible because we can't skip hooks (rules of react) and for that we need to create a query, put it in the cache and observe it. So we need a query key. The skipToken lets you skip running the query.