Skip to content

GraphQLError does not contains variables and context. Additional error objects. #662

Open
@nodkz

Description

@nodkz

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.pathproperty. 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.

@leebyron @schrockn what do you think about improving error object?


Some examples of error events which I got with my error catch setup for sentry.io

  • InvalidQuery example screen shot 2017-01-11 at 10 03 19
  • RuntimeError example screen shot 2017-01-11 at 10 32 26

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions