graphql-platform
graphql-platform copied to clipboard
Being able to log errors in Error middleware
Is your feature request related to a problem?
I'm using Mutation Conventions to handle errors by decorating my mutations with [Error(typeof(ValidationException))]. This works well by handling errors for me and I'm able to retrieve the error in the payload just fine. However I want to catch these errors somewhere so I can log them. I tried using IErrorFilter, but it doesn't catch errors when they are defined with the annotation. I also tried using ExecutionDiagnosticEventListener, but didn't find any events that listened to it.
The solution you'd like
Probably a method in ExecutionDiagnosticEventListener that could be overridden to catch the error message for errors, and be able to inject my logger and log them.
Product
Hot Chocolate
@michaelstaib should we add a hook to AddMutationConventions? e.g.
.AddMutationConcentions(options => options.OnError = (sp, errors) => {...})
No, that would feel wrong. I will think on this a bit.
i guess a mutation diagnostic observer would be a bit overkill
Aren't the diagnostic event listeners intended for logging https://chillicream.com/docs/hotchocolate/server/instrumentation ?
@resah no, a this are not really errors ... its schema types and they do not conform with standard GraphQL errors. GraphQL errors = Technical Errors ... these schema types represent domain errors aka business errors.