connectrpc / connect-query-es

TypeScript-first expansion pack for TanStack Query that gives you Protobuf superpowers.
https://connectrpc.com/docs/web/query/getting-started
Apache License 2.0
237 stars 17 forks source link

`enabled` option does not work as expected #317

Closed JuoCode closed 10 months ago

JuoCode commented 10 months ago

https://github.com/connectrpc/connect-query-es/blob/94ee6e86abbb7fc497c88d5900de457cfc9eb688/packages/connect-query/src/use-query.ts#L61-L64

I think that's the problem.

paul-sachs commented 10 months ago

Yeah we've typically used the symbol disableQuery to indicate a disabled query. The disableQuery symbol makes it easier to guarantee typesafety on the input combined with a valid query function. To make that more explicit, we should probably remove the enabled prop as a possible input since it's generated based on input.

paul-sachs commented 10 months ago

On closer examination of this, I think it would be consistent to still support the enabled option along with the explicit disableQuery since it will lead to less ternaries all over the place. Opened #318 to add this in.