Sha256: b70d658abc4421b9bdf01d05c2599c8352244336c8242417e5e6794285469b7f

Contents?: true

Size: 1.16 KB

Versions: 26

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe GraphQL::StaticValidation::FragmentTypesExist do
  let(:document) { GraphQL.parse("
    query getCheese {
      cheeese(id: 1) {
        ... on Cheese { source }
        ... on Nothing { whatever }
        ... somethingFields
        ... cheeseFields
      }
    }

    fragment somethingFields on Something {
      something
    }
    fragment cheeseFields on Cheese {
      fatContent
    }
  ")}

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

  it 'finds non-existent types on fragments' do
    assert_equal(2, errors.length)
    inline_fragment_error =  {
      "message"=>"No such type Something, so it can't be a fragment condition",
      "locations"=>[{"line"=>11, "column"=>5}]
    }
    assert_includes(errors, inline_fragment_error, "on inline fragments")
    fragment_def_error = {
      "message"=>"No such type Nothing, so it can't be a fragment condition",
      "locations"=>[{"line"=>5, "column"=>9}]
    }
    assert_includes(errors, fragment_def_error, "on fragment definitions")
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

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