Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit 7e06f57

Browse files
bbakermanandimarek
authored andcommitted
Added transformed ES parameters
1 parent 48c6464 commit 7e06f57

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

src/main/java/graphql/execution/ExecutionStrategy.java

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,12 @@ protected CompletableFuture<ExecutionResult> completeField(ExecutionContext exec
318318

319319
NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, fieldTypeInfo);
320320

321-
ExecutionStrategyParameters newParameters = ExecutionStrategyParameters.newParameters()
322-
.typeInfo(fieldTypeInfo)
323-
.field(parameters.getField())
324-
.fields(parameters.getFields())
325-
.arguments(argumentValues)
326-
.source(fetchedValue)
327-
.nonNullFieldValidator(nonNullableFieldValidator)
328-
.path(parameters.getPath())
329-
.build();
321+
ExecutionStrategyParameters newParameters = parameters.transform(builder ->
322+
builder.typeInfo(fieldTypeInfo)
323+
.arguments(argumentValues)
324+
.source(fetchedValue)
325+
.nonNullFieldValidator(nonNullableFieldValidator)
326+
);
330327

331328
log.debug("'{}' completing field '{}'...", executionContext.getExecutionId(), fieldTypeInfo.getPath());
332329

@@ -436,14 +433,12 @@ protected CompletableFuture<ExecutionResult> completeValueForList(ExecutionConte
436433

437434
NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, wrappedTypeInfo);
438435

439-
ExecutionStrategyParameters newParameters = ExecutionStrategyParameters.newParameters()
440-
.typeInfo(wrappedTypeInfo)
441-
.fields(parameters.getFields())
442-
.nonNullFieldValidator(nonNullableFieldValidator)
443-
.path(indexedPath)
444-
.field(parameters.getField())
445-
.source(item)
446-
.build();
436+
ExecutionStrategyParameters newParameters = parameters.transform(builder ->
437+
builder.typeInfo(wrappedTypeInfo)
438+
.nonNullFieldValidator(nonNullableFieldValidator)
439+
.path(indexedPath)
440+
.source(item)
441+
);
447442

448443
return completeValue(executionContext, newParameters);
449444
});
@@ -542,12 +537,12 @@ protected CompletableFuture<ExecutionResult> completeValueForObject(ExecutionCon
542537
ExecutionTypeInfo newTypeInfo = typeInfo.treatAs(resolvedObjectType);
543538
NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, newTypeInfo);
544539

545-
ExecutionStrategyParameters newParameters = ExecutionStrategyParameters.newParameters()
546-
.typeInfo(newTypeInfo)
547-
.fields(subFields)
548-
.nonNullFieldValidator(nonNullableFieldValidator)
549-
.path(parameters.getPath())
550-
.source(result).build();
540+
ExecutionStrategyParameters newParameters = parameters.transform(builder ->
541+
builder.typeInfo(newTypeInfo)
542+
.fields(subFields)
543+
.nonNullFieldValidator(nonNullableFieldValidator)
544+
.source(result)
545+
);
551546

552547
// Calling this from the executionContext to ensure we shift back from mutation strategy to the query strategy.
553548

@@ -579,21 +574,21 @@ protected Object unboxPossibleOptional(Object result) {
579574
return null;
580575
}
581576
} else if (result instanceof OptionalInt) {
582-
OptionalInt optional = (OptionalInt)result;
577+
OptionalInt optional = (OptionalInt) result;
583578
if (optional.isPresent()) {
584579
return optional.getAsInt();
585580
} else {
586581
return null;
587582
}
588583
} else if (result instanceof OptionalDouble) {
589-
OptionalDouble optional = (OptionalDouble)result;
584+
OptionalDouble optional = (OptionalDouble) result;
590585
if (optional.isPresent()) {
591586
return optional.getAsDouble();
592587
} else {
593588
return null;
594589
}
595590
} else if (result instanceof OptionalLong) {
596-
OptionalLong optional = (OptionalLong)result;
591+
OptionalLong optional = (OptionalLong) result;
597592
if (optional.isPresent()) {
598593
return optional.getAsLong();
599594
} else {

src/main/java/graphql/execution/ExecutionStrategyParameters.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ private Builder(ExecutionStrategyParameters oldParameters) {
112112
this.fields = oldParameters.fields;
113113
this.arguments = oldParameters.arguments;
114114
this.nonNullableFieldValidator = oldParameters.nonNullableFieldValidator;
115+
this.path = oldParameters.path;
116+
this.currentField = oldParameters.currentField;
115117
}
116118

117119
public Builder typeInfo(ExecutionTypeInfo type) {

0 commit comments

Comments
 (0)