Exception filters with GraphQL
See original GitHub issueI’m submitting a…
[ ] Regression
[ x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
I follow this documentation https://docs.nestjs.com/exception-filters for apply a filter for exception in a graphql resolver, over a mutation function. But the exception is never catch.
Expected behavior
Catch the exception in graphql resolvers.
Minimal reproduction of the problem with instructions
The resolver works fine, and the exceptions reaches the response in the graphiql request.
This is the classes i use
@Resolver()
export class UserResolver {
@Mutation('users')
@UseFilters(HttpException)
public async findUsers() {
throw new InternalServerErrorException();
}
}
@Catch()
export class HttpException implements ExceptionFilter {
catch(exception: any, host: ArgumentsHost) {
console.log('Cathing exception');
}
}
What is the motivation / use case for changing the behavior?
Environment
Nest version: X.Y.Z
For Tooling issues:
- Node version: 9.4.0
- Platform: Linux
Others:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Error handling - Apollo GraphQL Docs
Example: Filtering errors based on other properties. When generating an error (e.g., new GraphQLError("Failure!") ), the error's message is the most common ...
Read more >Error Filter - Hot Chocolate v10 - ChilliCream GraphQL Platform
GraphQL errors in Hot Chocolate are passed to the query result by returning an instance of IError or an enumerable of IError in...
Read more >How to modify HTTPException message in nestjs graphql ...
I want to modify the exception messages with translated messages. Like this is the result of console.log(exception.getResponse()); { statusCode: ...
Read more >Understanding GraphQL Error Handling Mechanisms in ...
The handler wraps 4 things: the thrown custom exception (the RuntimeException), the exception message, the error locations, and the extensions, within an ...
Read more >Error Handling in GraphQL With Spring Boot - Baeldung
By default, any exception during request processing is handled by the ExceptionResolversExceptionHandler class that implements the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I believe this feature has been added with version 6.0.0 . You can find a working example in the docs here https://docs.nestjs.com/graphql/tooling#exception-filters
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.