Sha256: 7b93a3712ee85b20afde8bb9badec28d0a9ef7e57709b037413ae40814893641

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require "spec_helper"

describe GraphQL::StaticValidation::VariablesAreInputTypes do
  let(:query_string) {'
    query getCheese(
      $id:        Int = 1,
      $str:       [String!],
      $interface: AnimalProduct!,
      $object:    Milk = 1,
      $objects:   [Cheese]!,
    ) {
      cheese(id: $id) { source }
    }
  '}

  let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::VariablesAreInputTypes]) }
  let(:query) { GraphQL::Query.new(DummySchema, query_string) }
  let(:errors) { validator.validate(query) }

  it "finds variables whose types are invalid" do
    expected = [
      {
        "message"=>"AnimalProduct isn't a valid input type (on $interface)",
        "locations"=>[{"line"=>5, "column"=>7}]
      },
      {
        "message"=>"Milk isn't a valid input type (on $object)",
        "locations"=>[{"line"=>6, "column"=>7}]
      },
      {
        "message"=>"Cheese isn't a valid input type (on $objects)",
        "locations"=>[{"line"=>7, "column"=>7}]
      }
    ]
    assert_equal(expected, errors)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
graphql-0.15.3 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.15.2 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.14.2 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.15.1 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.15.0 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.14.1 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.14.0 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.13.0 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb