Class: GraphQL::StaticValidation::FieldsAreDefinedOnType

Inherits:
Object
  • Object
show all
Includes:
Message::MessageHelper
Defined in:
lib/graphql/static_validation/rules/fields_are_defined_on_type.rb

Constant Summary collapse

IS_FIELD =
Proc.new {|f| f.is_a?(GraphQL::Language::Nodes::Field) }

Instance Method Summary collapse

Methods included from Message::MessageHelper

#message

Instance Method Details

#validate(context) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/graphql/static_validation/rules/fields_are_defined_on_type.rb', line 6

def validate(context)
  visitor = context.visitor
  visitor[GraphQL::Language::Nodes::Field] << -> (node, parent) {
    return if context.skip_field?(node.name)
    parent_type = context.object_types[-2]
    parent_type = parent_type.unwrap
    validate_field(context.errors, node, parent_type, parent)
  }
end