question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception filters with GraphQL

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Drago96commented, Mar 17, 2019

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

0reactions
lock[bot]commented, Sep 23, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found