Sha256: 2930bb9ede0b49cf9b2948ffdef7427e7f27958f03073c289b686422bec6285d

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

describe GraphQL::StaticValidation::FragmentsAreOnCompositeTypes do
  include StaticValidationHelpers

  let(:query_string) {%|
    query getCheese {
      cheese(id: 1) {
        ... on Cheese {
          source
          ... on Boolean {
            something
          }
        }
        ... intFields
        ... on DairyProduct {
          ... on Cheese {
            flavor
          }
        }
        ... on DairyProductInput {
          something
        }
      }
    }

    fragment intFields on Int {
      something
    }
  |}

  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}],
        "fields"=>["query getCheese", "cheese", "... on Cheese", "... on Boolean"],
      },
      {
        "message"=>"Invalid fragment on type DairyProductInput (must be Union, Interface or Object)",
        "locations"=>[{"line"=>16, "column"=>9}],
        "fields"=>["query getCheese", "cheese", "... on DairyProductInput"],
      },
      {
        "message"=>"Invalid fragment on type Int (must be Union, Interface or Object)",
        "locations"=>[{"line"=>22, "column"=>5}],
        "fields"=>["fragment intFields"],
      },
    ]
    assert_equal(expected, errors)
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
graphql-1.2.6 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.2.5 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.2.4 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.2.3 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.2.2 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.2.1 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.2.0 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.1.0 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.0.0 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.19.4 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.19.3 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.19.2 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.19.1 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-0.19.0 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb