py_gql.exc#

This module implements all the exceptions relevant to py_gql.

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.GraphQLResponseError(message='')[source]#

Bases: py_gql.exc.GraphQLError

Implementors of this are suitable for usage in GraphQL responses and exposing to end users.

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

to_dict()[source]#

Convert the exception to a dictionnary that can be serialized to JSON and exposed in a GraphQL response.

Return type

Dict[str, Any]

Returns

JSON serializable representation of the error.

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

property highlighted#

Message followed by a view of the source document pointing at the exact location of the error.

Type

str

Return type

str

to_dict()[source]#

Convert the exception to a dictionnary that can be serialized to JSON and exposed in a GraphQL response.

Return type

Dict[str, Any]

Returns

JSON serializable representation of the error.

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

Bases: py_gql.exc.GraphQLSyntaxError

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

Parameters
  • position (int) – 0-indexed position locating the syntax error

  • source (str) – Source string from which the syntax error originated

exception py_gql.exc.NonTerminatedString(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.UnexpectedToken(message, position, source)[source]#

Bases: py_gql.exc.GraphQLSyntaxError

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 parse node(s) in the source document.

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 dictionnary that can be serialized to JSON and exposed in a GraphQL response.

Return type

Dict[str, Any]

Returns

JSON serializable representation of the error.

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

Bases: py_gql.exc.GraphQLLocatedError, ValueError

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

Bases: py_gql.exc.InvalidValue

exception py_gql.exc.UnknownVariable(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.ScalarParsingError(message, nodes=None, path=None)[source]#

Bases: py_gql.exc.InvalidValue

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.UnknownType(message='')[source]#

Bases: py_gql.exc.SchemaError, KeyError

exception py_gql.exc.ValidationError(message, nodes=None, 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 dictionnary that can be serialized to JSON and exposed in a GraphQL response.

Return type

Dict[str, Any]

Returns

JSON serializable representation of the error.

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

Bases: py_gql.exc.ExecutionError

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]

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

Bases: py_gql.exc.GraphQLLocatedError

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.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 dictionnary that can be serialized to JSON and exposed in a GraphQL response.

Return type

Dict[str, Any]

Returns

JSON serializable representation of the error.

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

Bases: py_gql.exc.GraphQLLocatedError

Error that occured when parsing and / or applying a schema definition document (SDL).

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

Bases: py_gql.exc.SDLError

Error that occured when applying a schema or type extension node to an existing schema.

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

Bases: py_gql.exc.SDLError

Error that occured when applying schema directives.