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

Instance Method Summary collapse

Methods included from Message::MessageHelper

#message

Instance Method Details

#validate(context) ⇒ Object



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

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