graphql-java-kickstart/graphql-java-servlet

GraphQLServletListener.RequestCallback.onError not being called even though an exception throws

muhdalavu opened this issue · 2 comments

Describe the bug
I should be able to handle the Exception from the GraphQLServletListener

To Reproduce
Steps to reproduce the behavior:
In Asynchronus Excecution, Even there are exception in the response, the onError callback not being called.

Expected behavior
OnError mothod should be called
[In the below code the exceptionlly method not being called.]
file

private CompletableFuture<Void> handle(
      FutureExecutionResult futureResult,
      HttpServletRequest request,
      HttpServletResponse response,
      ListenerHandler listenerHandler) {
    return futureResult
        .thenApplyQueryResult()
        .thenAccept(
            it -> {
              listenerHandler.beforeFlush();
              writeResultResponse(futureResult.getInvocationInput(), it, request, response);
            })
        .thenAccept(it -> listenerHandler.onSuccess())
        .exceptionally(
            t ->
                writeErrorResponse(
                    futureResult.getInvocationInput(), request, response, listenerHandler, t))
        .thenAccept(it -> listenerHandler.onFinally());
  }

Screenshot 2022-06-23 at 7 24 41 PM

Do you have an example project or even better a unit test in a fork of this project reproducing this issue?

I think we can close this bug since the code is changed and now the handle method calls the listenerHandler.onError when an exception is catched.

See: https://github.com/graphql-java-kickstart/graphql-java-servlet/pull/442/files#diff-a166ddb02fc54c24bbd3a3759107eebb065981ac3824adf877c1e134afd1a3ccR107-R118