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



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

def validate(context)
  visitor = context.visitor
  visitor[GraphQL::Language::Nodes::Argument] << ->(node, parent) {
    case parent
    when 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::InputObjectType)
          return
        end
      end
    when GraphQL::Language::Nodes::Directive
      parent_defn = context.schema.directives[parent.name]
    when GraphQL::Language::Nodes::Field
      parent_defn = context.field_definition
    else
      raise "Unexpected argument parent: #{parent.class} (##{parent})"
    end
    validate_node(parent, node, parent_defn, context)
  }
end