Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/graphql/introspection/introspection_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
}
}
}
Expand Down
48 changes: 48 additions & 0 deletions spec/graphql/introspection/introspection_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,52 @@
it "runs" do
assert(result["data"])
end

it "handles deeply nested (<= 7) 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::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