Sha256: 38fe9b1309d4bad28084f177d77444045a46b66c318bc612a688ac7e49f0c20f

Contents?: true

Size: 1.26 KB

Versions: 15

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::StaticValidation::ArgumentNamesAreUnique do
  include StaticValidationHelpers

  describe "field arguments" do
    let(:query_string) { <<-GRAPHQL
    query GetStuff {
      c1: cheese(id: 1, id: 2) { flavor }
      c2: cheese(id: 2) { flavor }
    }
    GRAPHQL
    }

    it "finds duplicate names" do
      assert_equal 1, errors.size

      error = errors.first
      assert_equal 'There can be only one argument named "id"', error["message"]
      assert_equal [{ "line" => 2, "column" => 18}, { "line" => 2, "column" => 25 }], error["locations"]
      assert_equal ["query GetStuff", "c1"], error["path"]
    end
  end

  describe "directive arguments" do
    let(:query_string) { <<-GRAPHQL
    query GetStuff {
      c1: cheese(id: 1) @include(if: true, if: true) { flavor }
      c2: cheese(id: 2) @include(if: true) { flavor }
    }
    GRAPHQL
    }

    it "finds duplicate names" do
      assert_equal 1, errors.size

      error = errors.first
      assert_equal 'There can be only one argument named "if"', error["message"]
      assert_equal [{ "line" => 2, "column" => 34}, { "line" => 2, "column" => 44 }], error["locations"]
      assert_equal ["query GetStuff", "c1"], error["path"]
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
graphql-1.9.11 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.10 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.9 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.8 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.7 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.6 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.5 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.4 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.3 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.2 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.1 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.0 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.0.pre4 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.0.pre3 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb
graphql-1.9.0.pre2 spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb