Sha256: 3a49fa01eccb4b7086aef6b6898a69a6b02277b756c6764f7cd3c52caff5c7db

Contents?: true

Size: 1.37 KB

Versions: 76

Compression:

Stored size: 1.37 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}],
        "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

76 entries across 76 versions & 1 rubygems

Version Path
graphql-1.8.18 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.17 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.16 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.15 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.14 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.13 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.12 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.9.0.pre1 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.11 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.10 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.9 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.8 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.7 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.6 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.5 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.4 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.3 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.2 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.1 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb
graphql-1.8.0 spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb