Skip to content

Latest commit

 

History

History
78 lines (62 loc) · 3.07 KB

error_handling.rst

File metadata and controls

78 lines (62 loc) · 3.07 KB

Error Handing

Local errors

If gql detects locally that something does not correspond to the GraphQL specification, then gql may raise a GraphQLError from graphql-core.

This may happen for example:

  • if your query is not valid
  • if your query does not correspond to your schema
  • if the result received from the backend does not correspond to the schema if parse_results is set to True

Transport errors

If an error happens with the transport, then gql may raise a :class:`TransportError <gql.transport.exceptions.TransportError>`

Here are the possible Transport Errors:

HTTP

For HTTP transports, we should get a json response which contain data or errors fields. If that is not the case, then the returned error depends whether the http return code is below 400 or not.

  • json response:
    • with data or errors keys:
      • no errors key -> no exception
      • errors key -> raise TransportQueryError
    • no data or errors keys:
      • http code < 400: raise TransportProtocolError
      • http code >= 400: raise TransportServerError
  • not a json response:
    • http code < 400: raise TransportProtocolError
    • http code >= 400: raise TransportServerError