Sha256: debb1cbf74c29a344e826b609b8f0b32b3a8f6e4b9c86bc7b00d03abc83a3e72

Contents?: true

Size: 1.03 KB

Versions: 26

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe GraphQL::StaticValidation::VariablesAreInputTypes do
  let(:document) { GraphQL.parse('
    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(:errors) { validator.validate(document) }

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
graphql-0.11.1 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.11.0 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.10.9 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.10.8 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.10.7 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.10.6 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.10.5 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.10.4 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.10.3 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.10.2 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.10.1 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.10.0 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.9.5 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.9.4 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.9.3 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.9.2 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.8.1 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.8.0 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.7.1 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.7.0 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb