Validation

GraphQL Validation

The graphql.validation package fulfills the Validation phase of fulfilling a GraphQL result.

graphql.validation.validate(schema: graphql.type.schema.GraphQLSchema, document_ast: graphql.language.ast.DocumentNode, rules: Sequence[Type[graphql.validation.rules.ASTValidationRule]] = None, type_info: graphql.utilities.type_info.TypeInfo = None, max_errors: int = None) → List[graphql.error.graphql_error.GraphQLError]

Implements the “Validation” section of the spec.

Validation runs synchronously, returning a list of encountered errors, or an empty list if no errors were encountered and the document is valid.

A list of specific validation rules may be provided. If not provided, the default list of rules defined by the GraphQL specification will be used.

Each validation rule is a ValidationRule object which is a visitor object that holds a ValidationContext (see the language/visitor API). Visitor methods are expected to return GraphQLErrors, or lists of GraphQLErrors when invalid.

Optionally a custom TypeInfo instance may be provided. If not provided, one will be created from the provided schema.

class graphql.validation.ASTValidationContext(ast: graphql.language.ast.DocumentNode, on_error: Callable[[graphql.error.graphql_error.GraphQLError], None])

Bases: object

Utility class providing a context for validation of an AST.

An instance of this class is passed as the context attribute to all Validators, allowing access to commonly useful contextual information from within a validation rule.

__init__(ast: graphql.language.ast.DocumentNode, on_error: Callable[[graphql.error.graphql_error.GraphQLError], None]) → None

Initialize self. See help(type(self)) for accurate signature.

get_fragment(name: str) → Optional[graphql.language.ast.FragmentDefinitionNode]
get_fragment_spreads(node: graphql.language.ast.SelectionSetNode) → List[graphql.language.ast.FragmentSpreadNode]
get_recursively_referenced_fragments(operation: graphql.language.ast.OperationDefinitionNode) → List[graphql.language.ast.FragmentDefinitionNode]
on_error(error: graphql.error.graphql_error.GraphQLError)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.ASTValidationRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.language.visitor.Visitor

Visitor for validation of an AST.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.SDLValidationContext(ast: graphql.language.ast.DocumentNode, schema: Optional[graphql.type.schema.GraphQLSchema], on_error: Callable[[graphql.error.graphql_error.GraphQLError], None])

Bases: graphql.validation.validation_context.ASTValidationContext

Utility class providing a context for validation of an SDL AST.

An instance of this class is passed as the context attribute to all Validators, allowing access to commonly useful contextual information from within a validation rule.

__init__(ast: graphql.language.ast.DocumentNode, schema: Optional[graphql.type.schema.GraphQLSchema], on_error: Callable[[graphql.error.graphql_error.GraphQLError], None]) → None

Initialize self. See help(type(self)) for accurate signature.

get_fragment(name: str) → Optional[graphql.language.ast.FragmentDefinitionNode]
get_fragment_spreads(node: graphql.language.ast.SelectionSetNode) → List[graphql.language.ast.FragmentSpreadNode]
get_recursively_referenced_fragments(operation: graphql.language.ast.OperationDefinitionNode) → List[graphql.language.ast.FragmentDefinitionNode]
on_error(error: graphql.error.graphql_error.GraphQLError)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.SDLValidationRule(context: graphql.validation.validation_context.SDLValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Visitor for validation of an SDL AST.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.SDLValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.ValidationContext(schema: graphql.type.schema.GraphQLSchema, ast: graphql.language.ast.DocumentNode, type_info: graphql.utilities.type_info.TypeInfo, on_error: Callable[[graphql.error.graphql_error.GraphQLError], None])

Bases: graphql.validation.validation_context.ASTValidationContext

Utility class providing a context for validation using a GraphQL schema.

An instance of this class is passed as the context attribute to all Validators, allowing access to commonly useful contextual information from within a validation rule.

__init__(schema: graphql.type.schema.GraphQLSchema, ast: graphql.language.ast.DocumentNode, type_info: graphql.utilities.type_info.TypeInfo, on_error: Callable[[graphql.error.graphql_error.GraphQLError], None]) → None

Initialize self. See help(type(self)) for accurate signature.

get_argument()
get_directive()
get_field_def()
get_fragment(name: str) → Optional[graphql.language.ast.FragmentDefinitionNode]
get_fragment_spreads(node: graphql.language.ast.SelectionSetNode) → List[graphql.language.ast.FragmentSpreadNode]
get_input_type()
get_parent_input_type()
get_parent_type()
get_recursive_variable_usages(operation: graphql.language.ast.OperationDefinitionNode) → List[graphql.validation.validation_context.VariableUsage]
get_recursively_referenced_fragments(operation: graphql.language.ast.OperationDefinitionNode) → List[graphql.language.ast.FragmentDefinitionNode]
get_type()
get_variable_usages(node: Union[graphql.language.ast.OperationDefinitionNode, graphql.language.ast.FragmentDefinitionNode]) → List[graphql.validation.validation_context.VariableUsage]
on_error(error: graphql.error.graphql_error.GraphQLError)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.ValidationRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Visitor for validation using a GraphQL schema.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.ExecutableDefinitionsRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Executable definitions

A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_document(node: graphql.language.ast.DocumentNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.FieldsOnCorrectTypeRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Fields on correct type

A GraphQL document is only valid if all fields selected are defined by the parent type, or are an allowed meta field such as __typename.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_field(node: graphql.language.ast.FieldNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.FragmentsOnCompositeTypesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Fragments on composite type

Fragments use a type condition to determine if they apply, since fragments can only be spread into a composite type (object, interface, or union), the type condition must also be a composite type.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_definition(node: graphql.language.ast.FragmentDefinitionNode, *_args)
enter_inline_fragment(node: graphql.language.ast.InlineFragmentNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.KnownArgumentNamesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.known_argument_names.KnownArgumentNamesOnDirectivesRule

Known argument names

A GraphQL field is only valid if all supplied arguments are defined by that field.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_argument(arg_node: graphql.language.ast.ArgumentNode, *args)
enter_directive(directive_node: graphql.language.ast.DirectiveNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.KnownDirectivesRule(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext])

Bases: graphql.validation.rules.ASTValidationRule

Known directives

A GraphQL document is only valid if all @directives are known by the schema and legally positioned.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext]) → None

Initialize self. See help(type(self)) for accurate signature.

enter_directive(node: graphql.language.ast.DirectiveNode, _key, _parent, _path, ancestors)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.KnownFragmentNamesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Known fragment names

A GraphQL document is only valid if all …Fragment fragment spreads refer to fragments defined in the same document.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_spread(node: graphql.language.ast.FragmentSpreadNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.KnownTypeNamesRule(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext])

Bases: graphql.validation.rules.ASTValidationRule

Known type names

A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext]) → None

Initialize self. See help(type(self)) for accurate signature.

enter_named_type(node: graphql.language.ast.NamedTypeNode, _key, parent: graphql.language.ast.Node, _path, ancestors: List[graphql.language.ast.Node])
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.LoneAnonymousOperationRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Lone anonymous operation

A GraphQL document is only valid if when it contains an anonymous operation (the query short-hand) that it contains only that one operation definition.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_document(node: graphql.language.ast.DocumentNode, *_args)
enter_operation_definition(node: graphql.language.ast.OperationDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.NoFragmentCyclesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

No fragment cycles

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

detect_cycle_recursive(fragment: graphql.language.ast.FragmentDefinitionNode)
enter_fragment_definition(node: graphql.language.ast.FragmentDefinitionNode, *_args)
enter_operation_definition(*_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.NoUndefinedVariablesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

No undefined variables

A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_operation_definition(*_args)
enter_variable_definition(node: graphql.language.ast.VariableDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_operation_definition(operation: graphql.language.ast.OperationDefinitionNode, *_args)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.NoUnusedFragmentsRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

No unused fragments

A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_definition(node: graphql.language.ast.FragmentDefinitionNode, *_args)
enter_operation_definition(node: graphql.language.ast.OperationDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_document(*_args)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.NoUnusedVariablesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

No unused variables

A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_operation_definition(*_args)
enter_variable_definition(definition: graphql.language.ast.VariableDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_operation_definition(operation: graphql.language.ast.OperationDefinitionNode, *_args)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.OverlappingFieldsCanBeMergedRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Overlapping fields can be merged

A selection set is only valid if all fields (including spreading any fragments) either correspond to distinct response names or can be merged without ambiguity.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_selection_set(selection_set: graphql.language.ast.SelectionSetNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.PossibleFragmentSpreadsRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Possible fragment spread

A fragment spread is only valid if the type condition could ever possibly be true: if there is a non-empty intersection of the possible parent types, and possible types which pass the type condition.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_spread(node: graphql.language.ast.FragmentSpreadNode, *_args)
enter_inline_fragment(node: graphql.language.ast.InlineFragmentNode, *_args)
get_fragment_type(name: str)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.ProvidedRequiredArgumentsRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.provided_required_arguments.ProvidedRequiredArgumentsOnDirectivesRule

Provided required arguments

A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_directive(directive_node: graphql.language.ast.DirectiveNode, *_args)
leave_field(field_node: graphql.language.ast.FieldNode, *_args)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.ScalarLeafsRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Scalar leafs

A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_field(node: graphql.language.ast.FieldNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.SingleFieldSubscriptionsRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Subscriptions must only include one field.

A GraphQL subscription is valid only if it contains a single root.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_operation_definition(node: graphql.language.ast.OperationDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.UniqueArgumentNamesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Unique argument names

A GraphQL field or directive is only valid if all supplied arguments are uniquely named.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_argument(node: graphql.language.ast.ArgumentNode, *_args)
enter_directive(*_args)
enter_field(*_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.UniqueDirectivesPerLocationRule(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext])

Bases: graphql.validation.rules.ASTValidationRule

Unique directive names per location

A GraphQL document is only valid if all non-repeatable directives at a given location are uniquely named.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext]) → None

Initialize self. See help(type(self)) for accurate signature.

enter(node: graphql.language.ast.Node, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.UniqueFragmentNamesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Unique fragment names

A GraphQL document is only valid if all defined fragments have unique names.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_definition(node: graphql.language.ast.FragmentDefinitionNode, *_args)
enter_operation_definition(*_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.UniqueInputFieldNamesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Unique input field names

A GraphQL input object value is only valid if all supplied fields are uniquely named.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_object_field(node: graphql.language.ast.ObjectFieldNode, *_args)
enter_object_value(*_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_object_value(*_args)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.UniqueOperationNamesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Unique operation names

A GraphQL document is only valid if all defined operations have unique names.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_definition(*_args)
enter_operation_definition(node: graphql.language.ast.OperationDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.UniqueVariableNamesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Unique variable names

A GraphQL operation is only valid if all its variables are uniquely named.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_operation_definition(*_args)
enter_variable_definition(node: graphql.language.ast.VariableDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.ValuesOfCorrectTypeRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Value literals of correct type

A GraphQL document is only valid if all value literals are of the type expected at their position.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_boolean_value(node: graphql.language.ast.BooleanValueNode, *_args)
enter_enum_value(node: graphql.language.ast.EnumValueNode, *_args)
enter_float_value(node: graphql.language.ast.FloatValueNode, *_args)
enter_int_value(node: graphql.language.ast.IntValueNode, *_args)
enter_list_value(node: graphql.language.ast.ListValueNode, *_args)
enter_null_value(node: graphql.language.ast.NullValueNode, *_args)
enter_object_field(node: graphql.language.ast.ObjectFieldNode, *_args)
enter_object_value(node: graphql.language.ast.ObjectValueNode, *_args)
enter_string_value(node: graphql.language.ast.StringValueNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

is_valid_value_node(node: graphql.language.ast.ValueNode) → None

Check whether this is a valid value node.

Any value literal may be a valid representation of a Scalar, depending on that scalar type.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.VariablesAreInputTypesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Variables are input types

A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_variable_definition(node: graphql.language.ast.VariableDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.VariablesInAllowedPositionRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Variables passed to field arguments conform to type

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_operation_definition(*_args)
enter_variable_definition(node: graphql.language.ast.VariableDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_operation_definition(operation: graphql.language.ast.OperationDefinitionNode, *_args)
report_error(error: graphql.error.graphql_error.GraphQLError)
graphql.validation.validate(schema: graphql.type.schema.GraphQLSchema, document_ast: graphql.language.ast.DocumentNode, rules: Sequence[Type[graphql.validation.rules.ASTValidationRule]] = None, type_info: graphql.utilities.type_info.TypeInfo = None, max_errors: int = None) → List[graphql.error.graphql_error.GraphQLError]

Implements the “Validation” section of the spec.

Validation runs synchronously, returning a list of encountered errors, or an empty list if no errors were encountered and the document is valid.

A list of specific validation rules may be provided. If not provided, the default list of rules defined by the GraphQL specification will be used.

Each validation rule is a ValidationRule object which is a visitor object that holds a ValidationContext (see the language/visitor API). Visitor methods are expected to return GraphQLErrors, or lists of GraphQLErrors when invalid.

Optionally a custom TypeInfo instance may be provided. If not provided, one will be created from the provided schema.

class graphql.validation.ASTValidationContext(ast: graphql.language.ast.DocumentNode, on_error: Callable[[graphql.error.graphql_error.GraphQLError], None])

Bases: object

Utility class providing a context for validation of an AST.

An instance of this class is passed as the context attribute to all Validators, allowing access to commonly useful contextual information from within a validation rule.

__init__(ast: graphql.language.ast.DocumentNode, on_error: Callable[[graphql.error.graphql_error.GraphQLError], None]) → None

Initialize self. See help(type(self)) for accurate signature.

get_fragment(name: str) → Optional[graphql.language.ast.FragmentDefinitionNode]
get_fragment_spreads(node: graphql.language.ast.SelectionSetNode) → List[graphql.language.ast.FragmentSpreadNode]
get_recursively_referenced_fragments(operation: graphql.language.ast.OperationDefinitionNode) → List[graphql.language.ast.FragmentDefinitionNode]
on_error(error: graphql.error.graphql_error.GraphQLError)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.ASTValidationRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.language.visitor.Visitor

Visitor for validation of an AST.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.SDLValidationContext(ast: graphql.language.ast.DocumentNode, schema: Optional[graphql.type.schema.GraphQLSchema], on_error: Callable[[graphql.error.graphql_error.GraphQLError], None])

Bases: graphql.validation.validation_context.ASTValidationContext

Utility class providing a context for validation of an SDL AST.

An instance of this class is passed as the context attribute to all Validators, allowing access to commonly useful contextual information from within a validation rule.

__init__(ast: graphql.language.ast.DocumentNode, schema: Optional[graphql.type.schema.GraphQLSchema], on_error: Callable[[graphql.error.graphql_error.GraphQLError], None]) → None

Initialize self. See help(type(self)) for accurate signature.

get_fragment(name: str) → Optional[graphql.language.ast.FragmentDefinitionNode]
get_fragment_spreads(node: graphql.language.ast.SelectionSetNode) → List[graphql.language.ast.FragmentSpreadNode]
get_recursively_referenced_fragments(operation: graphql.language.ast.OperationDefinitionNode) → List[graphql.language.ast.FragmentDefinitionNode]
on_error(error: graphql.error.graphql_error.GraphQLError)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.SDLValidationRule(context: graphql.validation.validation_context.SDLValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Visitor for validation of an SDL AST.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.SDLValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.ValidationContext(schema: graphql.type.schema.GraphQLSchema, ast: graphql.language.ast.DocumentNode, type_info: graphql.utilities.type_info.TypeInfo, on_error: Callable[[graphql.error.graphql_error.GraphQLError], None])

Bases: graphql.validation.validation_context.ASTValidationContext

Utility class providing a context for validation using a GraphQL schema.

An instance of this class is passed as the context attribute to all Validators, allowing access to commonly useful contextual information from within a validation rule.

__init__(schema: graphql.type.schema.GraphQLSchema, ast: graphql.language.ast.DocumentNode, type_info: graphql.utilities.type_info.TypeInfo, on_error: Callable[[graphql.error.graphql_error.GraphQLError], None]) → None

Initialize self. See help(type(self)) for accurate signature.

get_argument()
get_directive()
get_field_def()
get_fragment(name: str) → Optional[graphql.language.ast.FragmentDefinitionNode]
get_fragment_spreads(node: graphql.language.ast.SelectionSetNode) → List[graphql.language.ast.FragmentSpreadNode]
get_input_type()
get_parent_input_type()
get_parent_type()
get_recursive_variable_usages(operation: graphql.language.ast.OperationDefinitionNode) → List[graphql.validation.validation_context.VariableUsage]
get_recursively_referenced_fragments(operation: graphql.language.ast.OperationDefinitionNode) → List[graphql.language.ast.FragmentDefinitionNode]
get_type()
get_variable_usages(node: Union[graphql.language.ast.OperationDefinitionNode, graphql.language.ast.FragmentDefinitionNode]) → List[graphql.validation.validation_context.VariableUsage]
on_error(error: graphql.error.graphql_error.GraphQLError)
report_error(error: graphql.error.graphql_error.GraphQLError)
class graphql.validation.ValidationRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Visitor for validation using a GraphQL schema.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Rules

This list includes all validation rules defined by the GraphQL spec. The order of the rules in this list has been adjusted to lead to the most clear output when encountering multiple validation errors:

graphql.validation.specified_rules = FrozenList([...])

This list includes all validation rules defined by the GraphQL spec.

The order of the rules in this list has been adjusted to lead to the most clear output when encountering multiple validation errors.

Spec Section: “Executable Definitions”

class graphql.validation.ExecutableDefinitionsRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Executable definitions

A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_document(node: graphql.language.ast.DocumentNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Field Selections on Objects, Interfaces, and Unions Types”

class graphql.validation.FieldsOnCorrectTypeRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Fields on correct type

A GraphQL document is only valid if all fields selected are defined by the parent type, or are an allowed meta field such as __typename.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_field(node: graphql.language.ast.FieldNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Fragments on Composite Types”

class graphql.validation.FragmentsOnCompositeTypesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Fragments on composite type

Fragments use a type condition to determine if they apply, since fragments can only be spread into a composite type (object, interface, or union), the type condition must also be a composite type.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_definition(node: graphql.language.ast.FragmentDefinitionNode, *_args)
enter_inline_fragment(node: graphql.language.ast.InlineFragmentNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Argument Names”

class graphql.validation.KnownArgumentNamesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.known_argument_names.KnownArgumentNamesOnDirectivesRule

Known argument names

A GraphQL field is only valid if all supplied arguments are defined by that field.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_argument(arg_node: graphql.language.ast.ArgumentNode, *args)
enter_directive(directive_node: graphql.language.ast.DirectiveNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Directives Are Defined”

class graphql.validation.KnownDirectivesRule(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext])

Bases: graphql.validation.rules.ASTValidationRule

Known directives

A GraphQL document is only valid if all @directives are known by the schema and legally positioned.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext]) → None

Initialize self. See help(type(self)) for accurate signature.

enter_directive(node: graphql.language.ast.DirectiveNode, _key, _parent, _path, ancestors)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Fragment spread target defined”

class graphql.validation.KnownFragmentNamesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Known fragment names

A GraphQL document is only valid if all …Fragment fragment spreads refer to fragments defined in the same document.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_spread(node: graphql.language.ast.FragmentSpreadNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Fragment Spread Type Existence”

class graphql.validation.KnownTypeNamesRule(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext])

Bases: graphql.validation.rules.ASTValidationRule

Known type names

A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext]) → None

Initialize self. See help(type(self)) for accurate signature.

enter_named_type(node: graphql.language.ast.NamedTypeNode, _key, parent: graphql.language.ast.Node, _path, ancestors: List[graphql.language.ast.Node])
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Lone Anonymous Operation”

class graphql.validation.LoneAnonymousOperationRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Lone anonymous operation

A GraphQL document is only valid if when it contains an anonymous operation (the query short-hand) that it contains only that one operation definition.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_document(node: graphql.language.ast.DocumentNode, *_args)
enter_operation_definition(node: graphql.language.ast.OperationDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Fragments must not form cycles”

class graphql.validation.NoFragmentCyclesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

No fragment cycles

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

detect_cycle_recursive(fragment: graphql.language.ast.FragmentDefinitionNode)
enter_fragment_definition(node: graphql.language.ast.FragmentDefinitionNode, *_args)
enter_operation_definition(*_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “All Variable Used Defined”

class graphql.validation.NoUndefinedVariablesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

No undefined variables

A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_operation_definition(*_args)
enter_variable_definition(node: graphql.language.ast.VariableDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_operation_definition(operation: graphql.language.ast.OperationDefinitionNode, *_args)
report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Fragments must be used”

class graphql.validation.NoUnusedFragmentsRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

No unused fragments

A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_definition(node: graphql.language.ast.FragmentDefinitionNode, *_args)
enter_operation_definition(node: graphql.language.ast.OperationDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_document(*_args)
report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “All Variables Used”

class graphql.validation.NoUnusedVariablesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

No unused variables

A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_operation_definition(*_args)
enter_variable_definition(definition: graphql.language.ast.VariableDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_operation_definition(operation: graphql.language.ast.OperationDefinitionNode, *_args)
report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Field Selection Merging”

class graphql.validation.OverlappingFieldsCanBeMergedRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Overlapping fields can be merged

A selection set is only valid if all fields (including spreading any fragments) either correspond to distinct response names or can be merged without ambiguity.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_selection_set(selection_set: graphql.language.ast.SelectionSetNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Fragment spread is possible”

class graphql.validation.PossibleFragmentSpreadsRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Possible fragment spread

A fragment spread is only valid if the type condition could ever possibly be true: if there is a non-empty intersection of the possible parent types, and possible types which pass the type condition.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_spread(node: graphql.language.ast.FragmentSpreadNode, *_args)
enter_inline_fragment(node: graphql.language.ast.InlineFragmentNode, *_args)
get_fragment_type(name: str)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Argument Optionality”

class graphql.validation.ProvidedRequiredArgumentsRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.provided_required_arguments.ProvidedRequiredArgumentsOnDirectivesRule

Provided required arguments

A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_directive(directive_node: graphql.language.ast.DirectiveNode, *_args)
leave_field(field_node: graphql.language.ast.FieldNode, *_args)
report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Leaf Field Selections”

class graphql.validation.ScalarLeafsRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Scalar leafs

A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_field(node: graphql.language.ast.FieldNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Subscriptions with Single Root Field”

class graphql.validation.SingleFieldSubscriptionsRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Subscriptions must only include one field.

A GraphQL subscription is valid only if it contains a single root.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_operation_definition(node: graphql.language.ast.OperationDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Argument Uniqueness”

class graphql.validation.UniqueArgumentNamesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Unique argument names

A GraphQL field or directive is only valid if all supplied arguments are uniquely named.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_argument(node: graphql.language.ast.ArgumentNode, *_args)
enter_directive(*_args)
enter_field(*_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Directives Are Unique Per Location”

class graphql.validation.UniqueDirectivesPerLocationRule(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext])

Bases: graphql.validation.rules.ASTValidationRule

Unique directive names per location

A GraphQL document is only valid if all non-repeatable directives at a given location are uniquely named.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: Union[graphql.validation.validation_context.ValidationContext, graphql.validation.validation_context.SDLValidationContext]) → None

Initialize self. See help(type(self)) for accurate signature.

enter(node: graphql.language.ast.Node, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Fragment Name Uniqueness”

class graphql.validation.UniqueFragmentNamesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Unique fragment names

A GraphQL document is only valid if all defined fragments have unique names.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_definition(node: graphql.language.ast.FragmentDefinitionNode, *_args)
enter_operation_definition(*_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Input Object Field Uniqueness”

class graphql.validation.UniqueInputFieldNamesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Unique input field names

A GraphQL input object value is only valid if all supplied fields are uniquely named.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_object_field(node: graphql.language.ast.ObjectFieldNode, *_args)
enter_object_value(*_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_object_value(*_args)
report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Operation Name Uniqueness”

class graphql.validation.UniqueOperationNamesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Unique operation names

A GraphQL document is only valid if all defined operations have unique names.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_fragment_definition(*_args)
enter_operation_definition(node: graphql.language.ast.OperationDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Variable Uniqueness”

class graphql.validation.UniqueVariableNamesRule(context: graphql.validation.validation_context.ASTValidationContext)

Bases: graphql.validation.rules.ASTValidationRule

Unique variable names

A GraphQL operation is only valid if all its variables are uniquely named.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ASTValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_operation_definition(*_args)
enter_variable_definition(node: graphql.language.ast.VariableDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Value Type Correctness”

class graphql.validation.ValuesOfCorrectTypeRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Value literals of correct type

A GraphQL document is only valid if all value literals are of the type expected at their position.

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_boolean_value(node: graphql.language.ast.BooleanValueNode, *_args)
enter_enum_value(node: graphql.language.ast.EnumValueNode, *_args)
enter_float_value(node: graphql.language.ast.FloatValueNode, *_args)
enter_int_value(node: graphql.language.ast.IntValueNode, *_args)
enter_list_value(node: graphql.language.ast.ListValueNode, *_args)
enter_null_value(node: graphql.language.ast.NullValueNode, *_args)
enter_object_field(node: graphql.language.ast.ObjectFieldNode, *_args)
enter_object_value(node: graphql.language.ast.ObjectValueNode, *_args)
enter_string_value(node: graphql.language.ast.StringValueNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

is_valid_value_node(node: graphql.language.ast.ValueNode) → None

Check whether this is a valid value node.

Any value literal may be a valid representation of a Scalar, depending on that scalar type.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “Variables are Input Types”

class graphql.validation.VariablesAreInputTypesRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Variables are input types

A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_variable_definition(node: graphql.language.ast.VariableDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

report_error(error: graphql.error.graphql_error.GraphQLError)

Spec Section: “All Variable Usages Are Allowed”

class graphql.validation.VariablesInAllowedPositionRule(context: graphql.validation.validation_context.ValidationContext)

Bases: graphql.validation.rules.ValidationRule

Variables passed to field arguments conform to type

BREAK = True
IDLE = None
REMOVE = Ellipsis
SKIP = False
__init__(context: graphql.validation.validation_context.ValidationContext) → None

Initialize self. See help(type(self)) for accurate signature.

enter_operation_definition(*_args)
enter_variable_definition(node: graphql.language.ast.VariableDefinitionNode, *_args)
classmethod get_visit_fn(kind, is_leaving=False) → Callable

Get the visit function for the given node kind and direction.

leave_operation_definition(operation: graphql.language.ast.OperationDefinitionNode, *_args)
report_error(error: graphql.error.graphql_error.GraphQLError)