Sha256: 986d968c20f9455d0e290d9981165892e6569d5b5295db3e7dff509740699da4

Contents?: true

Size: 1.1 KB

Versions: 15

Compression:

Stored size: 1.1 KB

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)[:errors] }

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
graphql-0.18.14 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.13 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.12 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.11 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.10 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.9 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.8 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.7 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.6 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.5 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.4 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.3 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.2 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.1 spec/graphql/static_validation/rules/directives_are_defined_spec.rb
graphql-0.18.0 spec/graphql/static_validation/rules/directives_are_defined_spec.rb