Description
DataFetcherExceptionResolver
implementations need to be able to do non-blocking I/O and have access to the Reactor context, mirroring how a DataFetcher
is now supported to return Flux
or Mono
.
For a concrete case, Spring Security needs to access security context when resolving an exception and on WebFlux this is most naturally obtained through the Reactor Context. Once obtained, the security context itself is deferred, in the form of Mono<SecurityContext>
and hence the need for a non-blocking contract.
One option would be to change the contract to return Mono<List<GraphQLError>>
rather than List<GraphQLError>
. Another would be like a DataFetcher
to support flexible return types, in this case checking for GraphQLError
or a list, a Mono
, or a Flux
of them.
Ideally this would rely on a corresponding change in GraphQL Java to support an asynchronous DataFetcherExceptionHandler
or otherwise we would need to switch threads ourselves to absorb the potential for blocking.