Sha256: 4bcd70627cc32739feb7c38544627781ff601a2f385b571252c7a8ec566b41c0

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe "GraphQL::Introspection::INTROSPECTION_QUERY" do
  let(:schema)  { Class.new(Dummy::Schema) }
  let(:query_string) { GraphQL::Introspection::INTROSPECTION_QUERY }
  let(:result) { schema.execute(query_string) }

  before do
    schema.max_depth = 15
  end

  it "runs" do
    assert(result["data"])
  end

  it "is limited to the max query depth" do
    query_type =  GraphQL::ObjectType.define do
      name "DeepQuery"
       field :foo do
         type !GraphQL::ListType.new(
           of_type: !GraphQL::ListType.new(
             of_type: !GraphQL::ListType.new(
               of_type: GraphQL::FLOAT_TYPE
             )
           )
         )
       end
    end

     deep_schema = GraphQL::Schema.define do
       query query_type
     end

     result = deep_schema.execute(query_string)
     assert(GraphQL::Schema::Loader.load(result))
  end

  it "doesn't handle too deeply nested (< 8) schemas" do
    query_type =  GraphQL::ObjectType.define do
      name "DeepQuery"
       field :foo do
         type !GraphQL::ListType.new(
           of_type: !GraphQL::ListType.new(
             of_type: !GraphQL::ListType.new(
               of_type: !GraphQL::ListType.new(
                 of_type: GraphQL::FLOAT_TYPE
               )
             )
           )
         )
       end
    end

     deep_schema = GraphQL::Schema.define do
       query query_type
     end

     result = deep_schema.execute(query_string)
     assert_raises(KeyError) {
       GraphQL::Schema::Loader.load(result)
     }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql-1.9.11 spec/graphql/introspection/introspection_query_spec.rb