py_gql.exc#

This module implements all the exceptions exposed by this library.

exception py_gql.exc.CoercionError(message, node=None, path=None, value_path=None)[source]#

Bases: py_gql.exc.GraphQLLocatedError

exception py_gql.exc.ExecutionError(message='')[source]#

Bases: py_gql.exc.GraphQLResponseError

Error that prevented execution of a query.

Parameters:message (str) – Explanatory message
message#

Explanatory message

Type:str
to_dict()[source]#

Convert the exception to a dictionary.

The return value should be serializable to JSON for use in a GraphQL response.

Return type:Dict[str, Any]
exception py_gql.exc.ExtensionError(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.SDLError

Error that occurred when applying an extension node.

exception py_gql.exc.GraphQLError(message='')[source]#

Bases: Exception

Base GraphQL exception from which all other inherit.

You should prefer using one of its subclasses most of the time.

exception py_gql.exc.GraphQLLocatedError(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.GraphQLResponseError

Response error that can be traced back to specific position(s) and node(s).

Parameters:
message#

Explanatory message

Type:str
nodes#

Nodes relevant to the exception

Type:List[py_gql.lang.ast.Node]
path#

Location of the error during execution

Type:Optional[Sequence[Union[int, str]]]
to_dict()[source]#

Convert the exception to a dictionary.

The return value should be serializable to JSON for use in a GraphQL response.

Return type:Dict[str, Any]
exception py_gql.exc.GraphQLResponseError(message='')[source]#

Bases: py_gql.exc.GraphQLError

Errors suitable for use in responses and being exposed to end users.

See the relevant part of the spec for more information on response errors.

to_dict()[source]#

Convert the exception to a dictionary.

The return value should be serializable to JSON for use in a GraphQL response.

Return type:Dict[str, Any]
exception py_gql.exc.GraphQLSyntaxError(message, position, source)[source]#

Bases: py_gql.exc.GraphQLResponseError

Syntax error while parsing a GraphQL document (query or schema definition).

Parameters:
  • message (str) – Explanatory message
  • position (int) – 0-indexed position locating the syntax error
  • source (str) – Source string from which the syntax error originated
message#

Explanatory message

Type:str
position#

0-indexed position locating the syntax error

Type:int
source#

Source string from which the syntax error originated

Type:str
highlighted#

Message followed by the detailed location location of the error.

Return type:str
to_dict()[source]#

Convert the exception to a dictionary.

The return value should be serializable to JSON for use in a GraphQL response.

Return type:Dict[str, Any]
exception py_gql.exc.InvalidCharacter(message, position, source)[source]#

Bases: py_gql.exc.GraphQLSyntaxError

exception py_gql.exc.InvalidEscapeSequence(message, position, source)[source]#

Bases: py_gql.exc.GraphQLSyntaxError

exception py_gql.exc.InvalidOperationError(message='')[source]#

Bases: py_gql.exc.ExecutionError

exception py_gql.exc.InvalidValue(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.GraphQLLocatedError, ValueError

exception py_gql.exc.MultiCoercionError(errors)[source]#

Bases: py_gql.exc.CoercionError

Collection of multiple CoercionError.

Parameters:errors (Sequence[CoercionError]) – Wrapped errors
errors#

Wrapped errors

Type:Sequence[CoercionError]
exception py_gql.exc.NonTerminatedString(message, position, source)[source]#

Bases: py_gql.exc.GraphQLSyntaxError

exception py_gql.exc.ResolverError(message, nodes=None, path=None, extensions=None)[source]#

Bases: py_gql.exc.GraphQLLocatedError

Raised when an expected error happens during field resolution.

Subclass or raise this exception directly for use in your own resolvers in order for them to report errors instead of crashing the query execution.

If your exception exposes an extensions attribute it will be included in the serialized version without the need to override to_dict().

Parameters:
message#

Explanatory message

Type:str
nodes#

Node or nodes relevant to the exception

Type:List[py_gql.lang.ast.Node]
path#

Location of the error during execution

Type:Optional[Sequence[Union[int, str]]]
extensions#

Error extensions

Type:Optional[Mapping[str, Any]]
to_dict()[source]#

Convert the exception to a dictionary.

The return value should be serializable to JSON for use in a GraphQL response.

Return type:Dict[str, Any]
exception py_gql.exc.SDLError(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.GraphQLLocatedError

Any error that occurred while interpreting a schema definition document.

exception py_gql.exc.ScalarParsingError(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.InvalidValue

exception py_gql.exc.ScalarSerializationError(message='')[source]#

Bases: py_gql.exc.GraphQLError, ValueError

exception py_gql.exc.SchemaDirectiveError(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.SDLError

Error that occurred when applying schema directives.

exception py_gql.exc.SchemaError(message='')[source]#

Bases: py_gql.exc.GraphQLError

exception py_gql.exc.SchemaValidationError(errors)[source]#

Bases: py_gql.exc.SchemaError

exception py_gql.exc.UnexpectedCharacter(message, position, source)[source]#

Bases: py_gql.exc.GraphQLSyntaxError

exception py_gql.exc.UnexpectedEOF(position, source)[source]#

Bases: py_gql.exc.GraphQLSyntaxError

Document terminated before parsing could finish.

Parameters:
  • position (int) – 0-indexed position locating the syntax error
  • source (str) – Source string from which the syntax error originated
exception py_gql.exc.UnexpectedToken(message, position, source)[source]#

Bases: py_gql.exc.GraphQLSyntaxError

exception py_gql.exc.UnknownEnumValue(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.InvalidValue

exception py_gql.exc.UnknownType(message='')[source]#

Bases: py_gql.exc.SchemaError, KeyError

exception py_gql.exc.UnknownVariable(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.InvalidValue

exception py_gql.exc.ValidationError(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.GraphQLLocatedError

exception py_gql.exc.VariableCoercionError(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.GraphQLLocatedError

exception py_gql.exc.VariablesCoercionError(errors)[source]#

Bases: py_gql.exc.GraphQLError

Collection of multiple VariableCoercionError.

Parameters:errors (Sequence[VariableCoercionError]) – Wrapped errors
errors#

Wrapped errors

Type:Sequence[VariableCoercionError]