-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prisma.$on gives error #56
Comments
After removing nestjs-prisma from project and restructuring code, the error persists. Anyway, your guidance may help resolve the issue. |
Hi @jd4u is this still an issue? Is this issue reported in the prisma repo? |
not yet... the issue still persist in latest version of prisma without nestjs-prisma. I've communicated on slack, but for long not received any response. Not yet reported on prisma. |
Created the prisma case just now... Closing this topic. |
Can you try the following to satisfy the Instance of PrismaClient with // prisma.ts
import { Prisma, PrismaClient } from '@prisma/client';
export const prismaClient = new PrismaClient<
Prisma.PrismaClientOptions,
'query' | 'info' | 'warn' | 'error'
>({
log: [
{ level: 'query', emit: 'event' },
{ level: 'info', emit: 'event' },
{ level: 'warn', emit: 'event' },
{ level: 'error', emit: 'event' },
],
});
export type prismaClient = typeof prismaClient; Use import { Module } from '@nestjs/common';
import { CustomPrismaModule } from 'nestjs-prisma';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { prismaClient } from './prisma';
@Module({
imports: [
CustomPrismaModule.forRoot({
name: 'PrismaService',
client: prismaClient,
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {} Use the type of import { Inject, Injectable } from '@nestjs/common';
import { CustomPrismaService } from 'nestjs-prisma';
import { prismaClient } from './prisma';
@Injectable()
export class AppService {
constructor(
// ✅ use `prismaClient` from extension for correct type-safety
@Inject('PrismaService')
private prismaService: CustomPrismaService<prismaClient>,
) {
prismaService.client.$on('error', async () => {});
}
users() {
return this.prismaService.client.user.findMany();
}
} |
I have updated the Extension Example to include the nestjs-prisma/examples/extensions/src/prisma.extension.ts Lines 3 to 13 in 11ead05
|
Fixed in prisma/prisma#24133 |
After updating to latest version 4.14.0 of prisma, the following error is coming. nestjs-prisma is 0.20.0
Error: Argument of type '"error"' is not assignable to parameter of type '"beforeExit"'
The error is only while using nestjs-prisma (PrismaService or CustomPrismaService)
In the above screenshot, you can see all option tried. The prisma1 is created directly and works.
Do guide further...
The text was updated successfully, but these errors were encountered: