notiz-dev / nestjs-prisma

Easy Prisma support for your NestJS application
https://nestjs-prisma.dev
MIT License
587 stars 50 forks source link

Feature Request: add support for using PrismaClientExceptionFilter as a controller/gateway/method level filter #87

Open recursive-beast opened 11 months ago

recursive-beast commented 11 months ago

Using PrismaClientExceptionFilter as a filter for a nestjs gateway in this manner for example:

import { UseFilters } from '@nestjs/common';
import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';
import { PrismaClientExceptionFilter } from 'nestjs-prisma';

@UseFilters(PrismaClientExceptionFilter)
@WebSocketGateway()
export class AppGateway {
  @SubscribeMessage('message')
  handleMessage(client: any, payload: any): string {
    return 'Hello world!';
  }
}

errors with this in the console:

[Nest] 8884  - 24/11/2023, 22:17:06   ERROR [ExceptionHandler] Nest can't resolve dependencies of the PrismaClientExceptionFilter (?, Object). Please make sure that the argument Object at index [0] is available in the ChatModule context.

Potential solutions:
- Is ChatModule a valid NestJS module?
- If Object is a provider, is it part of the current ChatModule?
- If Object is exported from a separate @Module, is that module imported within ChatModule?
  @Module({
    imports: [ /* the Module containing Object */ ]
  })

nestjs can't inject the first argument of the constructor. I tried the same for a controller and It gives me the same error. Are there any plans to support this?