Sha256: e8d94f6fc9d32d9ab70e707b19758eab21da32b1702e175de92cb9df43765bfb

Contents?: true

Size: 1.2 KB

Versions: 15

Compression:

Stored size: 1.2 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)[:errors] }

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
graphql-0.18.14 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.13 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.12 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.11 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.10 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.9 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.8 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.7 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.6 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.5 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.4 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.3 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.2 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.1 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb
graphql-0.18.0 spec/graphql/static_validation/rules/variables_are_input_types_spec.rb