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

avoid wrapping materialized fieldValueObject in a CompletableFuture by samuelAndalon · Pull Request #3943 · graphql-java/graphql-java · GitHub

avoid wrapping materialized fieldValueObject in a CompletableFuture - #3943

Merged
bbakerman merged 1 commit into
graphql-java:masterfrom
samuelAndalon:avoid-wrapping-fvi-completable-future
Apr 30, 2025
Merged

avoid wrapping materialized fieldValueObject in a CompletableFuture#3943
bbakerman merged 1 commit into
graphql-java:masterfrom
samuelAndalon:avoid-wrapping-fvi-completable-future

Conversation

samuelAndalon commented Apr 29, 2025
edited
Loading

Copy link
Copy Markdown

While updating graphql-kotlin to graphql-java 23 found that completeField is still wrapping FieldValueInfo.fieldValueObject in a CompletableFuture for objects already materialized / in memory

this might be considered a follow up of the Completable Future wrapping change set that came in graphql-java 22
https://github.com/graphql-java/graphql-java/releases/tag/v22.0

I don't think this is a breaking change.

samuelAndalon changed the title avoid wrapping materialized fieldValueObject in a completable future avoid wrapping materialized fieldValueObject in a CompletableFuture Apr 29, 2025
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.

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

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);
 }

bbakerman left a comment

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

Nice catch - I am embarrassed I missed this in the great "materialised migration" effort

bbakerman added the performance work that is primarily targeted as performance improvements label Apr 29, 2025

Copy link
Copy Markdown
Author

all good! thank you, now I am curious the memory and CPU improvement this change will bring

bbakerman merged commit ea9104d into graphql-java:master Apr 30, 2025
samuelAndalon deleted the avoid-wrapping-fvi-completable-future branch April 30, 2025 16:34

Copy link
Copy Markdown
Author

@bbakerman I wonder if this can be cherry picked to version 22.x ? I can prepare the PR.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance work that is primarily targeted as performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL