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:
Thomas Trompette
2024-07-16 10:49:18 +02:00
committed by GitHub
parent d216bfdd4e
commit 34cbba5fd8
6 changed files with 77 additions and 24 deletions

View File

@ -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)));
}
}