ChilliCream / ChilliCream/graphql-platform

Being able to log errors in Error middleware

Open
#5,424 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ hot chocolate Area: Type System Next
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the Error middleware and Mutation Conventions handling around the [Error(typeof(ValidationException))] annotation, then compare the existing IErrorFilter and ExecutionDiagnosticEventListener extension points. Confirm how annotated errors flow into the payload and determine the appropriate listener entry point. Done means those errors can be observed for logging without breaking their existing payload handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, graphql
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.