Repository navigation
Adding support for making the exception handlers async - #2371
Merged
Merged
Conversation
andimarek
reviewed
Jun 4, 2021
| * | ||
| * @return a result that can contain custom formatted {@link graphql.GraphQLError}s | ||
| */ | ||
| default CompletionStage<DataFetcherExceptionHandlerResult> handleException(DataFetcherExceptionHandlerParameters handlerParameters) { |
Member
There was a problem hiding this comment.
I think we use CompletableFuture everywhere, no?
bbakerman
commented
Jun 4, 2021
| default CompletionStage<DataFetcherExceptionHandlerResult> handleException(DataFetcherExceptionHandlerParameters handlerParameters) { | ||
| DataFetcherExceptionHandlerResult result = onException(handlerParameters); | ||
| return CompletableFuture.completedFuture(result); | ||
| } |
Member
Author
There was a problem hiding this comment.
The consuming code only calls this method. It delegates back to the old sync method. So any current implementations will continue to work.
Later at some point we can remove the deprecated version for a breaking change
bbakerman
commented
Jun 4, 2021
| } | ||
| }) | ||
| .thenCompose(errorOrValue -> errorOrValue) | ||
| .thenApply(result -> unboxPossibleDataFetcherResult(executionContext, parameters, result)); |
Member
Author
There was a problem hiding this comment.
we need to flat map the above CF<T> back to a
Member
Author
|
I made it use that. I am confused as to whether CompletionStage is every
worth it and when to use it
…On Fri, 4 Jun 2021 at 18:43, Andreas Marek ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/main/java/graphql/execution/DataFetcherExceptionHandler.java
<#2371 (comment)>
:
> DataFetcherExceptionHandlerResult onException(DataFetcherExceptionHandlerParameters handlerParameters);
+
+ /**
+ * When an exception occurs during a call to a ***@***.*** DataFetcher} then this handler
+ * is called to shape the errors that should be placed in the ***@***.*** ExecutionResult#getErrors()}
+ * list of errors.
+ *
+ * @PARAM handlerParameters the parameters to this callback
+ *
+ * @return a result that can contain custom formatted ***@***.*** graphql.GraphQLError}s
+ */
+ default CompletionStage<DataFetcherExceptionHandlerResult> handleException(DataFetcherExceptionHandlerParameters handlerParameters) {
I think we use CompletableFuture everywhere, no?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2371 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMVWSOORI5QR6WOVCRFOT3TRCG4BANCNFSM46CLNQFQ>
.
|
Member
Author
Contributor
|
@bbakerman would it be possible to merge this PR? or at least the commit e7f5a91 ? |
andimarek
approved these changes
Jun 23, 2021
Member
Author
|
@dfa1 - done |
This was referenced Aug 3, 2021
Update dependency com.graphql-java:graphql-java to v17
graphql-java-kickstart/graphql-java-tools#560
Merged
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes the data fetching exception handlers async.
The old method is left in place for backwards compatibiility reasons but the new async version is the one called.
It will delegate back to the old sync method.
New implementations can use proper async processing in making fetching errros