Class: GraphQL::StaticValidation::ArgumentsAreDefined

Inherits:
ArgumentsValidator show all
Defined in:
lib/graphql/static_validation/rules/arguments_are_defined.rb

Instance Method Summary collapse

Methods inherited from ArgumentsValidator

#validate

Methods included from Message::MessageHelper

#message

Instance Method Details

#validate_node(parent, node, defn, context) ⇒ Object



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

def validate_node(parent, node, defn, context)
  argument_defn = context.warden.arguments(defn).find { |arg| arg.name == node.name }
  if argument_defn.nil?
    kind_of_node = node_type(parent)
    error_arg_name = parent_name(parent, defn)
    context.errors << message("#{kind_of_node} '#{error_arg_name}' doesn't accept argument '#{node.name}'", node, context: context)
    GraphQL::Language::Visitor::SKIP
  else
    nil
  end
end