Module: GraphQL::StaticValidation::NoDefinitionsArePresent

Includes:
Error::ErrorHelper
Defined in:
lib/graphql/static_validation/rules/no_definitions_are_present.rb

Instance Method Summary collapse

Methods included from Error::ErrorHelper

#error

Instance Method Details

#initializeObject



7
8
9
10
# File 'lib/graphql/static_validation/rules/no_definitions_are_present.rb', line 7

def initialize(*)
  super
  @schema_definition_nodes = []
end

#on_document(node, parent) ⇒ Object



33
34
35
36
37
38
# File 'lib/graphql/static_validation/rules/no_definitions_are_present.rb', line 33

def on_document(node, parent)
  super
  if @schema_definition_nodes.any?
    add_error(GraphQL::StaticValidation::NoDefinitionsArePresentError.new(%|Query cannot contain schema definitions|, nodes: @schema_definition_nodes))
  end
end

#on_invalid_node(node, parent) ⇒ Object Also known as: on_directive_definition, on_schema_definition, on_scalar_type_definition, on_object_type_definition, on_input_object_type_definition, on_interface_type_definition, on_union_type_definition, on_enum_type_definition, on_schema_extension, on_scalar_type_extension, on_object_type_extension, on_input_object_type_extension, on_interface_type_extension, on_union_type_extension, on_enum_type_extension



12
13
14
15
# File 'lib/graphql/static_validation/rules/no_definitions_are_present.rb', line 12

def on_invalid_node(node, parent)
  @schema_definition_nodes << node
  nil
end