Sha256: 54490bf530ac84630e80c24cb84f15c58e22e89654315eabc5c0806fa2651c34

Contents?: true

Size: 1.29 KB

Versions: 15

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true
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}],
          "path"=>["query getCheese"],
          "extensions"=>{"code"=>"directiveCannotBeApplied", "targetName"=>"queries", "name"=>"skip"}
        },
        {
          "message"=>"'@skip' can't be applied to fragment definitions (allowed: fields, fragment spreads, inline fragments)",
          "locations"=>[{"line"=>13, "column"=>33}],
           "path"=>["fragment whatever"],
           "extensions"=>{"code"=>"directiveCannotBeApplied", "targetName"=>"fragment definitions", "name"=>"skip"}
        },
      ]
      assert_equal(expected, errors)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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