-
Notifications
You must be signed in to change notification settings - Fork 1.1k
21.x backport 3525 max result nodes #3528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -239,7 +240,23 @@ protected CompletableFuture<FetchedValue> fetchField(ExecutionContext executionC | |||
MergedField field = parameters.getField(); | |||
GraphQLObjectType parentType = (GraphQLObjectType) parameters.getExecutionStepInfo().getUnwrappedNonNullType(); | |||
GraphQLFieldDefinition fieldDef = getFieldDef(executionContext.getGraphQLSchema(), parentType, field.getSingleField()); | |||
GraphQLCodeRegistry codeRegistry = executionContext.getGraphQLSchema().getCodeRegistry(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is moved down in this PR
In latest master we added one extra method to break up the logic here. The code registry is used in the method being called here
@@ -25,7 +25,7 @@ public enum CompleteValueType { | |||
private final CompletableFuture<ExecutionResult> fieldValue; | |||
private final List<FieldValueInfo> fieldValueInfos; | |||
|
|||
private FieldValueInfo(CompleteValueType completeValueType, CompletableFuture<ExecutionResult> fieldValue, List<FieldValueInfo> fieldValueInfos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has default visibility on current master
@@ -19,7 +19,7 @@ public class FetchedValue { | |||
private final Object localContext; | |||
private final ImmutableList<GraphQLError> errors; | |||
|
|||
private FetchedValue(Object fetchedValue, Object rawFetchedValue, ImmutableList<GraphQLError> errors, Object localContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has default visibility on current master
if ((maxNodes = executionContext.getGraphQLContext().get(MAX_RESULT_NODES)) != null) { | ||
if (resultNodesCount > maxNodes) { | ||
executionContext.getResultNodesInfo().maxResultNodesExceeded(); | ||
return new FieldValueInfo(NULL, completedFuture(ExecutionResult.newExecutionResult().build()), fieldValueInfos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In master this second argument is completedFuture(null)
. In this version it MUST be completedFuture(ExecutionResult.newExecutionResult().build())
This is because since 21.x was last released we have made a big change to remove unnecessary ExecutionResult objects. My test hung weirdly because in 21.x land, the engine never expects a null, it expects an ExecutionResult
return CompletableFuture.completedFuture(new FetchedValue(null, null, ImmutableKit.emptyList(), null)); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next two lines (variables field
and parentType
) are not part of max result backport. I have done this to make this method look as close as possible to master
@@ -274,6 +291,7 @@ protected CompletableFuture<FetchedValue> fetchField(ExecutionContext executionC | |||
.queryDirectives(queryDirectives) | |||
.build(); | |||
}); | |||
GraphQLCodeRegistry codeRegistry = executionContext.getGraphQLSchema().getCodeRegistry(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where the codeRegistry line got moved to
if ((maxNodes = executionContext.getGraphQLContext().get(MAX_RESULT_NODES)) != null) { | ||
if (resultNodesCount > maxNodes) { | ||
executionContext.getResultNodesInfo().maxResultNodesExceeded(); | ||
return CompletableFuture.completedFuture(new FetchedValue(null, null, ImmutableKit.emptyList(), null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FetchedValue
has a slightly different constructor in v21 (compared to master), however this line still means effectively the same thing (return early with null)
See the original PR #3525 for more details. This backports a max result nodes limit