I'm in the same boat, also needing exception details
and nothing is logged to the applications console
I suggest this is where we should add error logging, as opposed to the response returned to the GraphQL client.
Setting up proper logging will help us in Production as well as Development envs, if we run into an issue there.
We'll need to hook into Hot Chocolate's Diagnostics. There are several types of diagnostic events, I'm just going to set up one for execution events, as that's where the error is in my case. I was only able to test ResolverError, but the rest should work.
public class ErrorLoggingDiagnosticsEventListener : ExecutionDiagnosticEventListener
{
private readonly ILogger<ErrorLoggingDiagnosticsEventListener> log;
public ErrorLoggingDiagnosticsEventListener(
ILogger<ErrorLoggingDiagnosticsEventListener> log)
{
this.log = log;
}
public override void ResolverError(
IMiddlewareContext context,
IError error)
{
log.LogError(error.Exception, error.Message);
}
public override void TaskError(
IExecutionTask task,
IError error)
{
log.LogError(error.Exception, error.Message);
}
public override void RequestError(
IRequestContext context,
Exception exception)
{
log.LogError(exception, "RequestError");
}
public override void SubscriptionEventError(
SubscriptionEventContext context,
Exception exception)
{
log.LogError(exception, "SubscriptionEventError");
}
public override void SubscriptionTransportError(
ISubscription subscription,
Exception exception)
{
log.LogError(exception, "SubscriptionTransportError");
}
}
Now wire that up in startup config.
public void ConfigureServices(IServiceCollection services)
{
services
.AddGraphQLServer()
.AddDiagnosticEventListener<ErrorLoggingDiagnosticsEventListener>()
...
;
}
Exceptions are now logged to your configured sink for ILogger.