Skip to content

Commit 54fcf44

Browse files
author
Robert Mosolgo
authored
Merge pull request #3129 from rmosolgo/fix-deeply-nested-queries-again
Make sure stack error comes back in response
2 parents c4d7c4a + 459bc71 commit 54fcf44

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

lib/graphql/schema.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ def possible_types(type = nil, context = GraphQL::Query::NullContext)
11171117
next true unless type.kind.interface?
11181118
next true unless possible_type.kind.object?
11191119

1120-
# Use `.graphql_name` comparison to match legacy vs class-based types.
1120+
# Use `.graphql_name` comparison to match legacy vs class-based types.
11211121
# When we don't need to support legacy `.define` types, use `.include?(type)` instead.
11221122
possible_type.interfaces(context).any? { |interface| interface.graphql_name == type.graphql_name }
11231123
end if stored_possible_types
@@ -1673,7 +1673,7 @@ def add_subscription_extension_if_necessary
16731673
end
16741674

16751675
def query_stack_error(query, err)
1676-
query.analysis_errors.push(GraphQL::AnalysisError.new("This query is too large to execute."))
1676+
query.context.errors.push(GraphQL::ExecutionError.new("This query is too large to execute."))
16771677
end
16781678

16791679
private

spec/graphql/analysis/ast/max_query_depth_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@
144144
}
145145

146146
it "returns an error" do
147-
assert_equal ["This query is too large to execute."], query.static_errors.map(&:message)
147+
assert_equal ["This query is too large to execute."], query.result["errors"].map { |err| err["message"] }
148+
149+
# Make sure `Schema.execute` works too
150+
execute_result = schema.execute(query_string)
151+
assert_equal ["This query is too large to execute."], execute_result["errors"].map { |err| err["message"] }
148152
end
149153
end
150154
end

0 commit comments

Comments
 (0)