Skip to content

A start to #324 that provides a promise interface to executing querie#380

Merged
andimarek merged 1 commit intographql-java:masterfrom
bbakerman:completeable-future-signature
Jul 5, 2017
Merged

A start to #324 that provides a promise interface to executing querie#380
andimarek merged 1 commit intographql-java:masterfrom
bbakerman:completeable-future-signature

Conversation

@bbakerman
Copy link
Member

Any serial execution is really an async one that is deemed complete so we are able to implement the existing via this pattern

This puts the structure in place to allow us to write truly asynchronous execution strategies where the consumer gets to decide when to consume the result.

As it turns out we can re-implement all the current serial execution strategies via the CompletableFuture pattern that have completed immediately. And hence this calls the async versions of everything to get work done.

@bbakerman bbakerman added this to the 3.0.0 milestone May 1, 2017
@bbakerman
Copy link
Member Author

One other thing on this PR. it brings the Java implementation inline with the reference JS one because the JS one returns a Promise of a ExecutionResult and so does this (CompletableFure is the Java promise)

Copy link

Choose a reason for hiding this comment

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

@bbakerman, normally "async" is preferred mainly due to pronunciation: https://english.stackexchange.com/questions/39743/abbreviation-of-asynchronous

@bbakerman bbakerman added the breaking change requires a new major version to be relased label May 4, 2017
Copy link

Choose a reason for hiding this comment

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

CompletableStage

Copy link
Member Author

Choose a reason for hiding this comment

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

Since I want to be able to .join() in a variety of places I think we should leave this as CompleteableFuture

@andimarek
Copy link
Member

As discussed, we will do it in version 4

Copy link
Member

Choose a reason for hiding this comment

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

do we wanna still provide this method or break it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I left it in to allow easier migration BUT I think we should break it

that is implementors of ExecutionStrategy are required to produce promises

We can keep the outer ones in place as "sugar" for people who just want a ExecutionResult direct

Copy link
Member

Choose a reason for hiding this comment

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

yes, let us break the ExecutionStrategy but keep the blocking GraphQL.execute method.

Copy link
Member

Choose a reason for hiding this comment

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

do we wanna still provide this method or break it?

Copy link
Member

Choose a reason for hiding this comment

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

do we wanna still provide this method or break it?

Copy link
Member Author

Choose a reason for hiding this comment

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

see above

@andimarek
Copy link
Member

looks good for me as a first step.

@kaqqao
Copy link
Contributor

kaqqao commented Jun 18, 2017

Just a small nitpick: the naming (async vs asynch) is a bit hectic, and could use standardization.

@andimarek
Copy link
Member

@kaqqao I agree. We should use async everywhere imho.

@bbakerman
Copy link
Member Author

This is the approach we will take with async support in graphql-java 4.0

  1. make it return a promise aka a CompletionStage - it will still be sync under the covers because all execution strategies are sync

  2. then add a more complete AsyncExecutionStrategy for people to use. This will be a promise based on and not a reactive stream based one

  3. allow people to add their own which might well be a promise to a reactive stream say

  4. when Java 9 comes out, consider the new standardized reactive stream support then. This might probably involve a graphql-java 5.x

@andimarek andimarek force-pushed the completeable-future-signature branch from 4da4ef5 to 6af43b4 Compare July 5, 2017 02:26
@andimarek andimarek merged commit 3bbc155 into graphql-java:master Jul 5, 2017
@He-Pin
Copy link

He-Pin commented Jul 5, 2017

CompletableFuture should be CompletableStage

@andimarek
Copy link
Member

@hepin1989 we decided to use CompletableFuture everywhere for now, rather than the interface

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change requires a new major version to be relased

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants