Add interceptors for auto-resolvers (#6270)
Services exceptions are not catch when the endpoint comes from an auto-resolver. We want to remove auto-resolver but it requires to implement pagination by ourselves. As a quick fix, here are interceptors that will trigger the exception handler. I had a hard time making it generic so I finally added one interceptor for each since this is not supposed to stay
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
||||
|
||||
import { Observable, catchError } from 'rxjs';
|
||||
|
||||
import { relationMetadataGraphqlApiExceptionHandler } from 'src/engine/metadata-modules/relation-metadata/utils/relation-metadata-graphql-api-exception-handler.util';
|
||||
|
||||
export class RelationMetadataGraphqlApiExceptionInterceptor
|
||||
implements NestInterceptor
|
||||
{
|
||||
intercept(_: ExecutionContext, next: CallHandler): Observable<any> {
|
||||
return next
|
||||
.handle()
|
||||
.pipe(
|
||||
catchError((err) => relationMetadataGraphqlApiExceptionHandler(err)),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user