Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
avoid wrapping materialized fieldValueObject in a completable future
  • Loading branch information
Samuel Vazquez
Samuel Vazquez committed Apr 29, 2025
commit 2e25aa8f47da1f3257e184658d14b6e42e7de2d3
9 changes: 6 additions & 3 deletions src/main/java/graphql/execution/ExecutionStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,13 @@ private FieldValueInfo completeField(GraphQLFieldDefinition fieldDef, ExecutionC
);

FieldValueInfo fieldValueInfo = completeValue(executionContext, newParameters);

CompletableFuture<Object> executionResultFuture = fieldValueInfo.getFieldValueFuture();
ctxCompleteField.onDispatched();
executionResultFuture.whenComplete(ctxCompleteField::onCompleted);
if (fieldValueInfo.isFutureValue()) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I could've done this as well but it has the unchecked cast already handled internally by FieldValueInfo

 Object executionResult = fieldValueInfo.getFieldValueObject();
 ctxCompleteField.onDispatched();
  if (executionResult instanceof CompletableFuture) {
   @SuppressWarnings("unchecked")
    CompletableFuture<Object> executionResultFuture = (CompletableFuture<Object>) executionResult;
    executionResultFuture.whenComplete(ctxCompleteField::onCompleted);
 } else {
     ctxCompleteField.onCompleted(executionResult, null);
 }

CompletableFuture<Object> executionResultFuture = fieldValueInfo.getFieldValueFuture();
executionResultFuture.whenComplete(ctxCompleteField::onCompleted);
} else {
ctxCompleteField.onCompleted(fieldValueInfo.getFieldValueObject(), null);
}
return fieldValueInfo;
}

Expand Down