react-apollo-hooks
react-apollo-hooks copied to clipboard
api ergonomics
instead of returning an object from useQuery/useSubscription, (given that the number of parameters and their function do not change) returning a tuple(array) would allow users to de-structure the variable names as they see fit, similarly along the lines of useState.
it would allow multiple queries from the same function without name collisions and extra noise from additional temporary variables.
Hi @kyunghoon
I don't think this would be a very good idea because useQuery returns a lot of things. It returns loading, data, refetch, error, networkStatus, ..., just imagine having to define the right order for that.
If all you want to do is to rename the properties you can do it pretty easily using this form:
const { data: otherNameForData } = useQuery(...)
For me info check this post: https://wesbos.com/destructuring-renaming/