Sha256: 192f2da1ed3315dedf552d74cc1c478186bba73a5b4bd1c2aca4e58d2dc51ac9

Contents?: true

Size: 1.08 KB

Versions: 76

Compression:

Stored size: 1.08 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}],
          "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

76 entries across 76 versions & 1 rubygems

Version Path
graphql-1.8.18 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.17 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.16 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.15 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.14 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.13 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.12 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.9.0.pre1 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.11 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.10 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.9 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.8 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.7 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.6 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.5 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.4 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.3 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.2 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.1 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb
graphql-1.8.0 spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb