Asynchronous execution strategy#283
Conversation
There was a problem hiding this comment.
This for loop needs to be replaced with a construct that properly closes over the vars passed to resolveFieldAsync
There was a problem hiding this comment.
could make use of java8's stream.map.collect thing
There was a problem hiding this comment.
Good call. Thank you. What do you think otherwise?
There was a problem hiding this comment.
@hepin1989 replaced this with .collect(toMap()). Thanks again.
|
Good work! I think the last missing piece is a way to pass in a custom Executor in which the CompletableFuture's will execute. Edit: On a second look, i see that DataFetchers would be allowed to return a CompletionStage, therefore an Executor can be used by the user in their DataFetcher implementations. So i think this PR is good to go. |
|
@dminkovsky, I have just browsed through the code but will soon test it. One feature that it would be great to have would be the concept of DataFetcher dependencies when executing in parallel. A DataFetcher can depend on other DataFetchers or, a DataFetcher could unlock other DataFetchers. |
|
Awesome, thank you.
There seems to be an issue where an error is swallowed. I am going to look
into it today or tomorrow and write a test that confirms it.
Also I need to make sure this strategy conforms to the issue described in
#268
But I think all the non-error paths work fine.
Re: the DataFetcher behavior you describe, if I understand you correctly I
think that's how it's set up right now. If you can think of how to write a
test that ensures fetchers execute in the correct order (that's important
either way for accepting this PR) then I bet we could also describe what
you're saying here in those terms.
сб, 31 дек. 2016 г. в 0:51, crazyfrozenpenguin <[email protected]>:
… @dminkovsky <https://github.com/dminkovsky>, I have just browsed through
the code but will soon test it.
One feature that it would be great to have would be the concept of
DataFetcher dependencies when executing in parallel.
A DataFetcher can depend on other DataFetchers or, a DataFetcher could
unlock other DataFetchers.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#283 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANWZdf_0XnBgcS6DKtVRVk3i87Yul__ks5rNe1_gaJpZM4LR92_>
.
|
da0b587 to
0b2d9d3
Compare
|
@crazyfrozenpenguin identified and fixed the above-mentioned bug. Also fixed another issue. The update is forced pushed to this PR. Happy New Year. |
70174b3 to
9ed6aee
Compare
|
By the way, I also updated the SNAPSHOT version. It was |
85c8939 to
4257f66
Compare
|
How do you intend to release this? will the project move to java 8? or will you release this as a seperate project? |
|
What's the reason for Java 6? The only release with public updates is Java 8: |
|
@bmsantos The reason we still support Java 6 is that a lot of companies are still using it, even if there are no updates for it. |
|
@oexza yeah the plan is for a separate artifact. I have this PR here now to aid in peer review. As @andimarek says, there are still people on Java 6 using this, which I think is really cool. It would be nice to somehow isolate a 1.6 and 1.7 compatible core that they can keep using. What do you think? cc/ @bmsantos |
|
@dminkovsky and @andimarek, if you really want to keep offering support for 1.6, then yes, I don't think that there's any other option other than extract async code into its own jar - maybe graphql-java-async? |
|
@bmsantos Yeah that's the name I was thinking. |
|
Breaking this on its own jar might actually be a much better approach since async related releases/updates will be easier to do. Let me know if you need any help on this. |
|
That would be greatly appreciated!
Yeah, that's what I am thinking too. For example, fixing #268 is a bit difficult because the maintainers need to verify that the problem does not exist in all of the execution strategies (simple, executor service, and batched). #284 is related: with a clearer demarcation of API vs SPI, I think this would be much easier. |
|
Is there a plan a plan / date to release this? It would be really helpful on an actual project... |
|
Hi @Cafeinoman. Thanks for posting. I've had to take a few weeks away from this while I launch a project. I am using this in this project, so I will need to get back to it soon. I think this PR is in okay shape except for correct handling of null non-nullable field (#268). That issue needs to be fixed in the other execution strategies as well. I don't think it makes sense to "release" this until those issues are addressed. In the mean time, have you played with this branch? If you use it, please report any issues or PR improvements. |
|
Regarding #268, if anyone wants to tackle it:
As you will see, graphql-js execution tracks |
|
I'm trying to get some free cycles to put out a small version of a project that exercises graphql with Vert.x. This will help me (and maybe others) to quickly exercise and test the async move to a jar. I'll try to put a first sample by the end of this weekend. |
graphql-java async implmentation should allow for non-default CompletableFeatures as some users/frameworks/toolkits want to use their own thread pools.
|
Cool. All set.
…On Wed, Feb 22, 2017 at 10:23 AM, Dmitry Minkovsky ***@***.***> wrote:
Starting now, hopefully won't take too long.
вт, 21 февр. 2017 г. в 14:46, Bruno Santos ***@***.***>:
> Sounds good. If you want to rebase, that will be great. Otherwise I can
> always rebase it myself.
>
> Thanks
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#283 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AANWZVmge-Tg_8srM-3ABJhw46pEFwTXks5rez73gaJpZM4LR92_>
> .
>
|
|
Thanks, will get to it ASAP. |
|
@dminkovsky, I've created the graphql-java-async project here. In addition, a PR has been placed against your fork of graphql-java async branch. Let me know if you find any issues and/or have any questions. |
|
Thank you @bmsantos! I will take a look soon.
…On Thu, Feb 23, 2017 at 10:47 PM, Bruno Santos ***@***.***> wrote:
@dminkovsky <https://github.com/dminkovsky>, I've created the
graphql-java-async project here
<https://github.com/bmsantos/graphql-java-async>. In addition, a PR
<dminkovsky#3> has been placed
against your fork of graphql-java async branch.
Let me know if you find any issues and/or have any questions.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#283 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANWZQndnTwSgomrQfTeOpBZffeFX8Irks5rflLSgaJpZM4LR92_>
.
|
| super(graphQLSchema, queryStrategy, mutationStrategy); | ||
| } | ||
|
|
||
| public CompletionStage<ExecutionResult> executeAsync(String requestString) { |
There was a problem hiding this comment.
It would be more convenient if it returned CompletableFuture here.
|
You can do #toCompletableFuture() on a CompletionStage. Sorry for the late
reply.
…On Sat, Mar 11, 2017 at 1:38 PM, Denis Nedelyaev ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/main/java/graphql/GraphQLAsync.java
<#283 (comment)>
:
> +
+ private static Logger log = LoggerFactory.getLogger(GraphQLAsync.class);
+
+ public GraphQLAsync(GraphQLSchema graphQLSchema) {
+ super(graphQLSchema);
+ }
+
+ public GraphQLAsync(GraphQLSchema graphQLSchema, ExecutionStrategy queryStrategy) {
+ super(graphQLSchema, queryStrategy);
+ }
+
+ public GraphQLAsync(GraphQLSchema graphQLSchema, ExecutionStrategy queryStrategy, ExecutionStrategy mutationStrategy) {
+ super(graphQLSchema, queryStrategy, mutationStrategy);
+ }
+
+ public CompletionStage<ExecutionResult> executeAsync(String requestString) {
It would be more convenient if it returned CompletableFuture here.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#283 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANWZcQhqnd3ZDc5q0FTTazUB7c0Cb0Vks5rkuotgaJpZM4LR92_>
.
|
|
FYI: We are discussing an upgrade to Java 8: #338 |
|
@andimarek yeah I've kind of been following that. Just still trying to finish my project which is woefully overdue :(. Looking forward to crawling out of my hole and rejoining the world. |
|
fyi: we will look at that topic for version 4 |
|
Please have a look at #324 for the overall disucssion |
|
closing it, it will not get merged: we solved the different aspects of this PR in the meantime and we we just merged #380 as a first step in supporting async execution. Thanks a lot @dminkovsky |
Following up with #242 and #202, this is a working asynchronous execution strategy:
Calls are made through
GraphQLAsync, which extendsGraphQLand provides anexecuteAsyncmethod that returnsCompletionStage<ExecutionResult>.