Open Irutom opened 1 month ago
For anyone looking for a workaround, you can use the non-TanStack hook useConvexQuery()
:
const ordersResponse = useConvexQuery(
api.orders.getOrdersByCartIds,
!!cartDocIds?.length ? { cartDocIds: cartDocIds ?? [], fetchProducts: true }) : "skip"
// "skip" is a special value that causes the query not to run https://docs.convex.dev/client/react#skipping-queries
});
We should support this though, shouldn't be hard.
Why not just this method below?
const convex = useConvex();
// later
const result = await convex.query(api.asd);
The dependent queries @Irutom wants here are still reactive, just off sometimes when the arguments aren't available.
Convex query is executed even if the enabled condition is not met.
Query
Below is the error
https://tanstack.com/query/latest/docs/framework/react/guides/dependent-queries