Skip to content

Commit

Permalink
Merge pull request #308 from tahnok/master
Browse files Browse the repository at this point in the history
Support 7 level introspection query instead of 3
  • Loading branch information
Robert Mosolgo authored Oct 13, 2016
2 parents c1bb9e4 + fdd1db3 commit 72e19de
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
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

0 comments on commit 72e19de

Please sign in to comment.