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



2
3
4
5
6
7
8
9
10
# File 'lib/graphql/static_validation/rules/argument_literals_are_compatible.rb', line 2

def validate_node(parent, node, defn, context)
  return if node.value.is_a?(GraphQL::Language::Nodes::VariableIdentifier)
  validator = GraphQL::StaticValidation::LiteralValidator.new
  arg_defn = defn.arguments[node.name]
  valid = validator.validate(node.value, arg_defn.type)
  if !valid
    context.errors << message("Argument #{node.name} on #{parent.class.name.split("::").last} '#{parent.name}' has an invalid value", parent)
  end
end