class GraphQL::StaticValidation::ValidationContext
which tracks state as you climb in and out of different fields.
It also provides limited access to the {TypeStack} instance,
It holds a list of errors which each validator may add to.
It provides access to the schema & fragments which validators may read from.
It exposes a {GraphQL::Language::Visitor} where validators may add hooks. ({Language::Visitor#visit} is called in {Validator#validate})
The validation context gets passed to each validator.
def initialize(query, visitor_class)
def initialize(query, visitor_class) @query = query @literal_validator = LiteralValidator.new(context: query.context) @errors = [] @on_dependency_resolve_handlers = [] @visitor = visitor_class.new(document, self) end
def on_dependency_resolve(&handler)
def on_dependency_resolve(&handler) @on_dependency_resolve_handlers << handler end
def valid_literal?(ast_value, type)
def valid_literal?(ast_value, type) @literal_validator.validate(ast_value, type) end