Class: GraphQL::StaticValidation::ArgumentsValidator

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

Overview

Implement validate_node

Instance Method Summary collapse

Methods included from Message::MessageHelper

#message

Instance Method Details

#validate(context) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/graphql/static_validation/arguments_validator.rb', line 7

def validate(context)
  visitor = context.visitor
  visitor[GraphQL::Language::Nodes::Argument] << ->(node, parent) {
    if parent.is_a?(GraphQL::Language::Nodes::InputObject)
      arg_defn = context.argument_definition
      if arg_defn.nil?
        return
      else
        parent_defn = arg_defn.type.unwrap
        if parent_defn.is_a?(GraphQL::ScalarType)
          return
        end
      end
    elsif parent.is_a?(GraphQL::Language::Nodes::Directive)
      parent_defn = context.schema.directives[parent.name]
    else
      parent_defn = context.field_definition
    end
    validate_node(parent, node, parent_defn, context)
  }
end