-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GraphQL doesn't work well with BaseExceptionFilter
#5958
Comments
|
What I wanted to change here is to make if (host.getType() == 'http') {
const ctx = host.switchToHttp();
applicationRef.reply(ctx.getResponse(), message, statusCode);
} else {
// Let the RPC / GraphQL framework handle building the response.
throw exception;
} |
The problem with making the
Your suggestion of throwing the exception again is actually what's currently happening, as Kamil mentioned with the |
Not exactly, this is a different one than the GraphQL error we were also discussing. Here, if there's an exception in a graph QL context, the What I'm suggesting is just to make sure that host is of type HTTP before doing |
As I've said here #5958 (comment), |
Bug Report
Current behavior
When throwing an exception within a GraphQL resolver, and then using a global Exception filter that extends
BaseExceptionFilter
, there's an exception insideBaseExceptionFilter
.Input Code
CustomExceptionFilter
And then throw an error inside some GraphQL resolver:
Expected behavior
The original error should have been the one returned and not the exception from within
BaseExceptionFilter
.Possible Solution
When
BaseExceptionFilter
handles unknown exceptions, it useshost.getArgByIndex(1)
to build the response. However, this may be null for GraphQL queries as their execution context is different.Environment
The text was updated successfully, but these errors were encountered: