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,15 @@
|
||||
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
||||
|
||||
import { Observable, catchError } from 'rxjs';
|
||||
|
||||
import { fieldMetadataGraphqlApiExceptionHandler } from 'src/engine/metadata-modules/field-metadata/utils/field-metadata-graphql-api-exception-handler.util';
|
||||
|
||||
export class FieldMetadataGraphqlApiExceptionInterceptor
|
||||
implements NestInterceptor
|
||||
{
|
||||
intercept(_: ExecutionContext, next: CallHandler): Observable<any> {
|
||||
return next
|
||||
.handle()
|
||||
.pipe(catchError((err) => fieldMetadataGraphqlApiExceptionHandler(err)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user