You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding an IErrorFilter with dependencies, that is created using the provided ServiceFactory of .AddErrorFilter, the ErrorFilter is never instantiated, nor executed.
#2768
Closed
fredericbirke opened this issue
Dec 19, 2020
· 6 comments
public void ConfigureServices(IServiceCollection services)
{
services.AddGraphQLServer()
.AddErrorFilter(factory => new MyErrorFilter(factory.GetApplicationService<ILogger<MyErrorFilter>>()))
.AddQueryType<Query>();
}
public class MyErrorFilter: IErrorFilter
{
private readonly ILogger<MyErrorFilter> _myErrorFilter;
public MyErrorFilter(ILogger<MyErrorFilter> myErrorFilter)
{
_myErrorFilter = myErrorFilter;
}
public IError OnError(IError error)
{
Console.WriteLine("An Error occured!");
return error;
}
}
To Reproduce
Checkout https://github.com/fredericbirke/HcErrorFilterBug, start it and fire the ping query using BCP.
If you set the breakpoints, you will see, that the ErrorFilter is never instantiated or used.
Expected behavior
The ErrorFilter should work exactly the same way as the ErrorFilter, that has no dependencies to other services from the DI-Container.
The text was updated successfully, but these errors were encountered:
Does anyone have any way of working around this issue.
I'm trying to get an ILogger into my Error filter so I can log all errors that come from the api but obviously can't inject the ILogger at the moment as the API breaks when I add this in
Describe the bug
To Reproduce
Checkout https://github.com/fredericbirke/HcErrorFilterBug, start it and fire the ping query using BCP.
If you set the breakpoints, you will see, that the ErrorFilter is never instantiated or used.
Expected behavior
The ErrorFilter should work exactly the same way as the ErrorFilter, that has no dependencies to other services from the DI-Container.
The text was updated successfully, but these errors were encountered: