2

The python graphene documentation does not mention anything about graphQL error. Under what scenarios is it useful, does it have any advantage over a simple raise Exception('Authenication Failure : User is not registered') ?

I did my homework and found this in it's constructor,

def __init__(
    self,
    message,  # type: str
    nodes=None,  # type: Any
    stack=None,  # type: Optional[TracebackType]
    source=None,  # type: Optional[Any]
    positions=None,  # type: Optional[Any]
    locations=None,  # type: Optional[Any]
    path=None,  # type: Union[List[Union[int, str]], List[str], None]
    extensions=None,  # type: Optional[Dict[str, Any]]
)

But apart from message, I don't understand when the other options would be most useful. Some help would be greatly appreciated.

Shivansh Jagga
  • 1,541
  • 1
  • 15
  • 24

1 Answers1

3

The GraphQLError class on Graphene comes from graphql-core which is the Python implementation of GraphQL-JS, where you can find the same GraphQLError class.

This is used to get extra information about the location, the node kind and the stack trace of any validation/parsing error while executing a graphql query.

You can read more at the official spec doc :)

gdvalderrama
  • 713
  • 1
  • 17
  • 26
KingDarBoja
  • 1,033
  • 6
  • 12