Description
I setup logging GraphQL errors on Sentry.io and got several issues with GraphQLError
1. Determining a type of the error:
RuntimeError (when resolvers throw errors on execution) or InvalidQuery (when provided invalid query). Right now I qualify a type of error via GraphQLError.path
property. If it is empty then I got InvalidQuery, if it is an array then RuntimeError.
What do you think about additional Error objects GraphQLRuntimeError, GraphQLInvalidQueryError (inherited from GraphQLError)?
2. Lack of context
and variables
in GraphQLError
Query I can get via GraphQLError.source.body
, but did not found a proper way how to get variables and context.
Diving down to GraphQLError.nodes
for obtaining variables is too complicated.
Passing context to formatError
when defining express-graphql
middleware is possible. But looks weird.
So will be cool if these properties somehow will be added to the GraphQLError.