Sha256: 1a397bd647195817ca0c287eb5fbb9a3f7b887de2d0bad637007698ff0919e00

Contents?: true

Size: 1.28 KB

Versions: 26

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe GraphQL::StaticValidation::FragmentsAreOnCompositeTypes do
  let(:document) { GraphQL.parse(%|
    query getCheese {
      cheese(id: 1) {
        ... on Cheese {
          source
          ... on Boolean {
            something
          }
        }
        ... intFields
        ... on DairyProduct {
          name
        }
        ... on DairyProductInput {
          something
        }
      }
    }

    fragment intFields on Int {
      something
    }
  |)}

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

  it 'requires Object/Union/Interface fragment types' do
    expected = [
      {
        "message"=>"Invalid fragment on type Boolean (must be Union, Interface or Object)",
        "locations"=>[{"line"=>6, "column"=>11}]
      },
      {
        "message"=>"Invalid fragment on type DairyProductInput (must be Union, Interface or Object)",
        "locations"=>[{"line"=>14, "column"=>9}],
      },
      {
        "message"=>"Invalid fragment on type Int (must be Union, Interface or Object)",
        "locations"=>[{"line"=>20, "column"=>5}]
      },
    ]
    assert_equal(expected, errors)
  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_on_composite_types_spec.rb
graphql-0.11.0 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.10.9 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.10.8 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.10.7 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.10.6 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.10.5 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.10.4 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.10.3 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.10.2 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.10.1 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.10.0 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.9.5 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.9.4 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.9.3 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.9.2 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.8.1 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.8.0 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.7.1 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.7.0 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb