Currently the method in DataFetcherExceptionResolver
is Mono<List<GraphQLError>> resolveException(Throwable exception, DataFetchingEnvironment environment)
while the method in SubscriptionExceptionResolver
is Mono<List<GraphQLError>> resolveException(Throwable exception)
. It would be nice to have DataFetchingEnvironment
passed in as well to include more information in our error logs.
As a side note in DataFetcherExceptionResolver.resolveException
I've noticed that for some reason SecurityContextHolder.getContext().getAuthentication()
returns an instance of AnonymousAuthentication
when I know the user is authenticated (and the same piece of code works correctly elsewhere) and as a work-around I'm force to use environment.getGraphQlContext().get<SecurityContextImpl>(SecurityContext::class.name).getAuthentication()
to get the proper authentication instance. Same applies in SubscriptionExceptionResolver