Sha256: 8196fb25f923acee89599de674812514e4770ea84e960755ea4d8e3269687859

Contents?: true

Size: 1.62 KB

Versions: 15

Compression:

Stored size: 1.62 KB

Contents

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
graphql-1.9.11 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.10 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.9 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.8 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.7 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.6 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.5 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.4 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.3 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.2 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.1 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.0 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.0.pre4 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.0.pre3 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.0.pre2 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb