Sha256: 22f29175873bf4eeb48f853bba0c41ec7a6aeb904e6b1326f5a598953127f3f4

Contents?: true

Size: 1.13 KB

Versions: 76

Compression:

Stored size: 1.13 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}],
      "fields"=>["fragment somethingFields"],
    }
    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}],
      "fields"=>["query getCheese", "cheese", "... on Nothing"],
    }
    assert_includes(errors, fragment_def_error, "on fragment definitions")
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

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