Sha256: 96b3720749fc80219f8b2000f46b035f38e2a5218079d3b5cf8c250d4f151b1c

Contents?: true

Size: 893 Bytes

Versions: 26

Compression:

Stored size: 893 Bytes

Contents

require 'spec_helper'

describe GraphQL::StaticValidation::FragmentsAreUsed do
  let(:document) { GraphQL.parse("
    query getCheese {
      name,
      ...cheeseFields
      ...undefinedFields
    }
    fragment cheeseFields on Cheese { fatContent }
    fragment unusedFields on Cheese { is, not, used }
  ")}

  let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FragmentsAreUsed]) }
  let(:errors) { validator.validate(document) }

  it 'adds errors for unused fragment definitions' do
    assert_includes(errors, {"message"=>"Fragment unusedFields was defined, but not used", "locations"=>[{"line"=>8, "column"=>5}]})
  end

  it 'adds errors for undefined fragment spreads' do
    assert_includes(errors, {"message"=>"Fragment undefinedFields was used, but not defined", "locations"=>[{"line"=>5, "column"=>7}]})
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

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