Open simPod opened 7 months ago
Thank you, that's a very good writeup and it's clear that we have to change something.
We're still undecided if we'll solve this in runtime or by adjusting our types, but I've opened #11789 to help us along with the decision process here.
Issue Description
I'd like to resurrect https://github.com/apollographql/apollo-client/issues/11168 since issue got stale and closed.
As you can see in the graphql spec, the errors returned by the server are not required to specify e.g.
extensions
key.However,
if you look at the
GraphQLError
class, theextensions
field is not optionalhttps://github.com/graphql/graphql-js/blob/8e9813f8c283d94da66fad6fd9562432846c17d4/src/error/GraphQLError.ts#L89
That is achieved by taking server response and routing it through
GraphQLError
class' constructor:https://github.com/graphql/graphql-js/blob/8e9813f8c283d94da66fad6fd9562432846c17d4/src/error/GraphQLError.ts#L125
So that implies that using
GraphQLError[]
as a type forApolloError.graphQLErrors
is wrong since the server data were not manipulated and may not comply with theGraphQLError
interface.Link to Reproduction
https://spec.graphql.org/October2021/#sec-Errors.Error-result-format
Reproduction Steps
No response
@apollo/client
version3.9.1