Sha256: ed4d68ea77a417bb4ba4aeaff4cda5a4279adba068f198161373b581083b0f09

Contents?: true

Size: 926 Bytes

Versions: 26

Compression:

Stored size: 926 Bytes

Contents

require 'spec_helper'

describe GraphQL::StaticValidation::DirectivesAreDefined do
  let(:document) { GraphQL.parse("
    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(:errors) { validator.validate(document) }

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
graphql-0.11.1 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.11.0 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.10.9 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.10.8 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.10.7 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.10.6 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.10.5 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.10.4 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.10.3 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.10.2 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.10.1 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.10.0 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.9.5 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.9.4 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.9.3 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.9.2 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.8.1 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.8.0 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.7.1 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.7.0 spec/graphql/static_validation/rules/directives_are_defined_spec.rb