Open samdenty opened 3 years ago
I agree on usage, in general moving away from destructuring on the hooks in docs and as a general good practice, like you said:
const query = useQuery()
query.posts()
The hookless thing looks a bit crazy to me, but perhaps Pablo doesn't see any big downsides.
Does this issue means React users has to move away from the hook pattern?
Does this issue means React users has to move away from the hook pattern?
I don't think so
I don't agree with the proposal made here, there is component-aware stuff in the hooks, and non-suspense usage, which this pattern wouldn't allow at all
@samdenty If you want to make a separate branch implementing this logic as a proof of concept, feel free, but removing the hooks is 100% unlikely
We could enable usage of the hooks logic, without importing
useQuery
oruseSubscription
.Hooks make the code messier:
It's possible to detect whether we're rendering inside a React Component by doing
As GQless is a proxy, we could easily do this when you do
query.posts
. This shouldn't be in the core though, so the core could expose an API:inside this API, we could perform all the hook logic we currently do inside
useQuery
/useSubscription
.useSubscription
doesn't have any arguments to customize, so it could be removed.useQuery
has optional arguments, so we should make it require you to pass optionsI think this should work, I'm curious to hear your thoughts