Sha256: f1f9385c0236895d3a200b90423e80dd8ea2584bc5953c9d2f4a89aee11e4787

Contents?: true

Size: 707 Bytes

Versions: 21

Compression:

Stored size: 707 Bytes

Contents

class GraphQL::StaticValidation::VariablesAreInputTypes
  include GraphQL::StaticValidation::Message::MessageHelper

  def validate(context)
    context.visitor[GraphQL::Language::Nodes::Variable] << -> (node, parent) {
      validate_is_input_type(node, context)
    }
  end

  private

  def validate_is_input_type(node, context)
    type_name = get_type_name(node.type)
    type = context.schema.types[type_name]
    if !type.kind.input?
      context.errors << message("#{type.name} isn't a valid input type (on $#{node.name})", node)
    end
  end

  def get_type_name(ast_type)
    if ast_type.respond_to?(:of_type)
      get_type_name(ast_type.of_type)
    else
      ast_type.name
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
graphql-0.10.9 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.10.8 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.10.7 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.10.6 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.10.5 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.10.4 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.10.3 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.10.2 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.10.1 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.10.0 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.9.5 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.9.4 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.9.3 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.9.2 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.8.1 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.8.0 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.7.1 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.7.0 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.6.2 lib/graphql/static_validation/rules/variables_are_input_types.rb
graphql-0.6.1 lib/graphql/static_validation/rules/variables_are_input_types.rb