vuejs / apollo

🚀 Apollo/GraphQL integration for VueJS
http://apollo.vuejs.org
MIT License
6.02k stars 523 forks source link

[Typescript] On query result, wrong error attribute #752

Open orblazer opened 5 years ago

orblazer commented 5 years ago

Hello, When use query and method result on vue component the object data contains error but the type except errors.

Thanks.

dvic commented 5 years ago

I have the same problem.

Akryum commented 5 years ago

I'm sorry I don't understand what the issue is, could you please be more explicit?

orblazer commented 5 years ago

Hello, For explain, when we use smart query the type of error is defined from here : https://github.com/apollographql/apollo-client/blob/1098e428a013f94281d422fbaebc4bc741a007d1/packages/apollo-client/src/core/types.ts#L24

But is result object the error is : error

Akryum commented 5 years ago

I still don't understand, could you please provide some examples? Thanks!

orblazer commented 5 years ago

Im little stupid because i have already make that issue in the problem 2 on https://github.com/Akryum/vue-apollo/issues/605

Akryum commented 5 years ago

Is it fixed with the new types in latest versions?

dvic commented 5 years ago

@Akryum it's about the object passed into the result() callback: its type is ApolloQueryResult<T> but the problem is that the object received in this callback does not satisfy this interface. The errors field is missing and instead the field error (singular) is passed. I don't recall if the type is correct of this field (GraphQLError). I'll check with the latest RC and let you know.

dvic commented 5 years ago

@Akryum I can confirm this problem still exists with rc7, there is only an error field, instead of the errors?: ReadonlyArray<GraphQLError> field from ApolloQueryResult. The error field seems to be of type GraphQLError (the one on the error handler function).

Isn't this the place where the errors variable should be set https://github.com/Akryum/vue-apollo/blob/be6f8c580b0fedc0cff4f509fa4a099968492b95/src/components/ApolloQuery.js#L178-L184

Akryum commented 5 years ago

vue-apollo pass the result object from Apollo Client directly, so this is an issue with it rather than vue-apollo.