FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ExecutionStrategyParameters now has a direct transform without a Builder by bbakerman · Pull Request #3935 · graphql-java/graphql-java · GitHub

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

Filter by extension

Filter by extension .java  (5) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ public CompletableFuture<ExecutionResult> execute(ExecutionContext executionCont
CompletableFuture<List<Object>> resultsFuture = Async.eachSequentially(fieldNames, (fieldName, prevResults) -> {
MergedField currentField = fields.getSubField(fieldName);
ResultPath fieldPath = parameters.getPath().segment(mkNameForPath(currentField));
ExecutionStrategyParameters newParameters = parameters
.transform(builder -> builder.field(currentField).path(fieldPath));
ExecutionStrategyParameters newParameters = parameters.transform(currentField, fieldPath);

Object resolveSerialField = resolveSerialField(executionContext, dataLoaderDispatcherStrategy, newParameters);
return resolveSerialField;
return resolveSerialField(executionContext, dataLoaderDispatcherStrategy, newParameters);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

inlined variable

});

CompletableFuture<ExecutionResult> overallResult = new CompletableFuture<>();
Expand Down
34 changes: 13 additions & 21 deletions src/main/java/graphql/execution/ExecutionStrategy.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ DeferredExecutionSupport createDeferredExecutionSupport(ExecutionContext executi
MergedField currentField = fields.getSubField(fieldName);

ResultPath fieldPath = parameters.getPath().segment(mkNameForPath(currentField));
ExecutionStrategyParameters newParameters = parameters
.transform(builder -> builder.field(currentField).path(fieldPath).parent(parameters));
ExecutionStrategyParameters newParameters = parameters.transform(currentField, fieldPath, parameters);

if (!deferredExecutionSupport.isDeferredField(currentField)) {
Object fieldValueInfo = resolveFieldWithInfo(executionContext, newParameters);
Expand Down Expand Up @@ -627,12 +626,10 @@ private FieldValueInfo completeField(GraphQLFieldDefinition fieldDef, ExecutionC

NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, executionStepInfo);

ExecutionStrategyParameters newParameters = parameters.transform(builder ->
builder.executionStepInfo(executionStepInfo)
.source(fetchedValue.getFetchedValue())
.localContext(fetchedValue.getLocalContext())
.nonNullFieldValidator(nonNullableFieldValidator)
);
ExecutionStrategyParameters newParameters = parameters.transform(executionStepInfo,
nonNullableFieldValidator,
fetchedValue.getLocalContext(),
fetchedValue.getFetchedValue());

FieldValueInfo fieldValueInfo = completeValue(executionContext, newParameters);

Expand Down Expand Up @@ -790,13 +787,10 @@ protected FieldValueInfo completeValueForList(ExecutionContext executionContext,

FetchedValue value = unboxPossibleDataFetcherResult(executionContext, parameters, item);

ExecutionStrategyParameters newParameters = parameters.transform(builder ->
builder.executionStepInfo(stepInfoForListElement)
.nonNullFieldValidator(nonNullableFieldValidator)
.localContext(value.getLocalContext())
.path(indexedPath)
.source(value.getFetchedValue())
);
ExecutionStrategyParameters newParameters = parameters.transform(stepInfoForListElement,
nonNullableFieldValidator, indexedPath,
value.getLocalContext(), value.getFetchedValue());

fieldValueInfos.add(completeValue(executionContext, newParameters));
index++;
}
Expand Down Expand Up @@ -936,12 +930,10 @@ protected Object completeValueForObject(ExecutionContext executionContext, Execu
ExecutionStepInfo newExecutionStepInfo = executionStepInfo.changeTypeWithPreservedNonNull(resolvedObjectType);
NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, newExecutionStepInfo);

ExecutionStrategyParameters newParameters = parameters.transform(builder ->
builder.executionStepInfo(newExecutionStepInfo)
.fields(subFields)
.nonNullFieldValidator(nonNullableFieldValidator)
.source(result)
);
ExecutionStrategyParameters newParameters = parameters.transform(newExecutionStepInfo,
nonNullableFieldValidator,
subFields,
result);

// Calling this from the executionContext to ensure we shift back from mutation strategy to the query strategy.
return executionContext.getQueryStrategy().executeObject(executionContext, newParameters);
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package graphql.execution;

import graphql.Internal;
import graphql.PublicApi;
import graphql.execution.incremental.DeferredCallContext;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -115,6 +116,84 @@ public MergedField getField() {
return currentField;
}

@Internal

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good that it's Internal

ExecutionStrategyParameters transform(MergedField currentField,
ResultPath path) {
return new ExecutionStrategyParameters(executionStepInfo,
source,
localContext,
fields,
nonNullableFieldValidator,
path,
currentField,
parent,
deferredCallContext);
}

@Internal
ExecutionStrategyParameters transform(ExecutionStepInfo executionStepInfo,
NonNullableFieldValidator nonNullableFieldValidator,
MergedSelectionSet fields,
Object source) {
return new ExecutionStrategyParameters(executionStepInfo,
source,
localContext,
fields,
nonNullableFieldValidator,
path,
currentField,
parent,
deferredCallContext);
}

@Internal
ExecutionStrategyParameters transform(ExecutionStepInfo executionStepInfo,
NonNullableFieldValidator nonNullableFieldValidator,
ResultPath path,
Object localContext,
Object source) {
return new ExecutionStrategyParameters(executionStepInfo,
source,
localContext,
fields,
nonNullableFieldValidator,
path,
currentField,
parent,
deferredCallContext);
}

@Internal
ExecutionStrategyParameters transform(ExecutionStepInfo executionStepInfo,
NonNullableFieldValidator nonNullableFieldValidator,
Object localContext,
Object source) {
return new ExecutionStrategyParameters(executionStepInfo,
source,
localContext,
fields,
nonNullableFieldValidator,
path,
currentField,
parent,
deferredCallContext);
}

@Internal
ExecutionStrategyParameters transform(MergedField currentField,
ResultPath path,
ExecutionStrategyParameters parent) {
return new ExecutionStrategyParameters(executionStepInfo,
source,
localContext,
fields,
nonNullableFieldValidator,
path,
currentField,
parent,
deferredCallContext);
}

public ExecutionStrategyParameters transform(Consumer<Builder> builderConsumer) {
Builder builder = newParameters(this);
builderConsumer.accept(builder);
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private ExecutionStrategyParameters firstFieldOfSubscriptionSelection(ExecutionS
MergedField firstField = fields.getSubField(fields.getKeys().get(0));

ResultPath fieldPath = parameters.getPath().segment(mkNameForPath(firstField.getSingleField()));
return parameters.transform(builder -> builder.field(firstField).path(fieldPath));
return parameters.transform(firstField,fieldPath);
}

private ExecutionStepInfo createSubscribedFieldStepInfo(ExecutionContext executionContext, ExecutionStrategyParameters parameters) {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import graphql.execution.FieldValueInfo;
import graphql.execution.MergedField;
import graphql.execution.MergedSelectionSet;
import graphql.execution.ResultPath;
import graphql.execution.instrumentation.Instrumentation;
import graphql.incremental.IncrementalPayload;
import graphql.util.FpKit;
Expand Down Expand Up @@ -139,10 +140,11 @@ private Supplier<CompletableFuture<DeferredFragmentCall.FieldWithExecutionResult
ExecutionStrategyParameters callParameters = parameters.transform(builder ->
{
MergedSelectionSet mergedSelectionSet = MergedSelectionSet.newMergedSelectionSet().subFields(fields).build();
ResultPath path = parameters.getPath().segment(currentField.getResultKey());
builder.deferredCallContext(deferredCallContext)
.field(currentField)
.fields(mergedSelectionSet)
.path(parameters.getPath().segment(currentField.getResultKey()))
.path(path)
.parent(null); // this is a break in the parent -> child chain - it's a new start effectively
}
);
Expand Down

Back | FazBrowse Home | New Git URL