If I have understood correctly, I think you will find that they are not ‘returning’ objects or arrays, but rather using object and array destructuring which is a common javascript pattern frequently utilised in React.

It seems the Apollo team chose ‘named’ destructuring over tuples to avoid the pitfalls of having to declare many variables (which in the case of useQuery is many) in the correct order. Other hooks from React typically have just 2 values (the variable and its setter in the case of useState, for example).

I recommend having a look at some javascript resources on the topic of destructuring before checking out some general introductions to React’s hooks (from the overreacted blog, for example).

Frontend Developer at AMBOSS

Frontend Developer at AMBOSS