Sha256: b0d0e3a7e7b73490171bf0f6c4f399e93acaf506b93b9ee194f54b72698bb538

Contents?: true

Size: 975 Bytes

Versions: 8

Compression:

Stored size: 975 Bytes

Contents

require "spec_helper"

describe GraphQL::StaticValidation::DirectivesAreDefined do
  let(:query_string) {"
    query getCheese {
      okCheese: cheese(id: 1) {
        id @skip(if: true),
        source @nonsense(if: false)
        ... on Cheese {
          flavor @moreNonsense
        }
      }
    }
  "}

  let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::DirectivesAreDefined]) }
  let(:query) { GraphQL::Query.new(DummySchema, query_string) }
  let(:errors) { validator.validate(query) }

  describe "non-existent directives" do
    it "makes errors for them" do
      expected = [
        {
          "message"=>"Directive @nonsense is not defined",
          "locations"=>[{"line"=>5, "column"=>16}]
        }, {
          "message"=>"Directive @moreNonsense is not defined",
          "locations"=>[{"line"=>7, "column"=>18}]
        }
      ]
      assert_equal(expected, errors)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
graphql-0.15.3 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.15.2 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.14.2 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.15.1 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.15.0 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.14.1 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.14.0 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.13.0 spec/graphql/static_validation/rules/directives_are_defined_spec.rb