Module: GraphQL::StaticValidation::ArgumentsAreDefined

Defined in:
lib/graphql/static_validation/rules/arguments_are_defined.rb

Instance Method Summary collapse

Instance Method Details

#on_argument(node, parent) ⇒ Object



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

def on_argument(node, parent)
  parent_defn = parent_definition(parent)

  if parent_defn && context.warden.get_argument(parent_defn, node.name)
    super
  elsif parent_defn
    kind_of_node = node_type(parent)
    error_arg_name = parent_name(parent, parent_defn)
    add_error(GraphQL::StaticValidation::ArgumentsAreDefinedError.new(
      "#{kind_of_node} '#{error_arg_name}' doesn't accept argument '#{node.name}'",
      nodes: node,
      name: error_arg_name,
      type: kind_of_node,
      argument_name: node.name,
      parent: parent_defn
    ))
  else
    # Some other weird error
    super
  end
end