Sha256: ac42d4288bbdd52a441d2b8d6eae27c42d051c97d209d1ecdb16373e95b6f1cf

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"

describe GraphQL::StaticValidation::DirectivesAreInValidLocations do
  include StaticValidationHelpers
  let(:query_string) {"
    query getCheese @skip(if: true) {
      okCheese: cheese(id: 1) {
        id @skip(if: true),
        source
        ... on Cheese @skip(if: true) {
          flavor
          ... whatever
        }
      }
    }

    fragment whatever on Cheese @skip(if: true) {
      id
    }
  "}

  describe "invalid directive locations" do
    it "makes errors for them" do
      expected = [
        {
          "message"=> "'@skip' can't be applied to queries (allowed: fields, fragment spreads, inline fragments)",
          "locations"=>[{"line"=>2, "column"=>21}],
          "fields"=>["query getCheese"],
        },
        {
          "message"=>"'@skip' can't be applied to fragment definitions (allowed: fields, fragment spreads, inline fragments)",
          "locations"=>[{"line"=>13, "column"=>33}],
           "fields"=>["fragment whatever"],
        },
      ]
      assert_equal(expected, errors)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
graphql-1.2.6 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.2.5 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.2.4 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.2.3 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.2.2 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.2.1 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.2.0 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.1.0 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.0.0 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-0.19.4 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-0.19.3 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-0.19.2 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-0.19.1 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-0.19.0 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb