graphql-java-servlet icon indicating copy to clipboard operation
graphql-java-servlet copied to clipboard

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

Open muhdalavu opened this issue 3 years ago • 1 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

muhdalavu avatar Jun 23 '22 13:06 muhdalavu

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

oliemansm avatar Aug 17 '22 17:08 oliemansm

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

federicorispo avatar Jun 16 '23 15:06 federicorispo