Sha256: c483ff69dbb9d665c70a741e6e74c66c07477e17ff71a8d03946659c7576b85a

Contents?: true

Size: 1.27 KB

Versions: 15

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::StaticValidation::FragmentTypesExist do
  include StaticValidationHelpers

  let(:query_string) {"
    query getCheese {
      cheese(id: 1) {
        ... on Cheese { source }
        ... on Nothing { whatever }
        ... somethingFields
        ... cheeseFields
      }
    }

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

  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}],
      "path"=>["fragment somethingFields"],
      "extensions"=>{"code"=>"undefinedType", "typeName"=>"Something"}
    }
    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}],
      "path"=>["query getCheese", "cheese", "... on Nothing"],
      "extensions"=>{"code"=>"undefinedType", "typeName"=>"Nothing"}
    }
    assert_includes(errors, fragment_def_error, "on fragment definitions")
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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