Class: GraphQL::StaticValidation::ArgumentLiteralsAreCompatible

Inherits:
ArgumentsValidator show all
Defined in:
lib/graphql/static_validation/rules/argument_literals_are_compatible.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
# File 'lib/graphql/static_validation/rules/argument_literals_are_compatible.rb', line 5

def validate_node(parent, node, defn, context)
  return if node.value.is_a?(GraphQL::Language::Nodes::VariableIdentifier)
  arg_defn = defn.arguments[node.name]
  return unless arg_defn
  if !context.valid_literal?(node.value, arg_defn.type)
    kind_of_node = node_type(parent)
    error_arg_name = parent_name(parent, defn)
    context.errors << message("Argument '#{node.name}' on #{kind_of_node} '#{error_arg_name}' has an invalid value. Expected type '#{arg_defn.type}'.", parent, context: context)
  end
end