millsp
millsp
PPrisma
Created by Virgile on 10/7/2024 in #help-and-questions
Still unable to get Optimize working in my NestJS app.
Hey @Virgile thanks for your reproduction, it was really helpful. We uncovered a bug for which I have built a fix for. Before we release it, I just want to make sure that everything works as expected. Here are some changes you'll need to make: 1. Install the development version to try it out (make sure not to include any caret in the version ^):
"@prisma/extension-optimize": "0.0.0-dev.202411151707"
"@prisma/extension-optimize": "0.0.0-dev.202411151707"
2. Remove Object.assign workaround, as in my tests it does not work as described. Instead to this:
function ExtendedPrismaClient() {
const client = new PrismaClient().$extends(
withOptimize({ apiKey: process.env.PRISMA_OPTIMIZE_API_KEY ?? "" })
);

return class {
constructor() {
// biome-ignore lint/correctness/noConstructorReturn: <explanation>
return client;
}
} as new () => typeof client;
}

@Injectable()
export class PrismaService extends ExtendedPrismaClient() {}
function ExtendedPrismaClient() {
const client = new PrismaClient().$extends(
withOptimize({ apiKey: process.env.PRISMA_OPTIMIZE_API_KEY ?? "" })
);

return class {
constructor() {
// biome-ignore lint/correctness/noConstructorReturn: <explanation>
return client;
}
} as new () => typeof client;
}

@Injectable()
export class PrismaService extends ExtendedPrismaClient() {}
You will need this workaround until https://github.com/prisma/prisma/issues/18628 is implemented. This drawback specifically impacts Nest.js. With the workaround, full type safety should be preserved. We will likely release this fix early next week, in the mean time let me know if you have any feedback. I don't have a timeline, however, on the specific issue I have linked above. Thanks! Feel free to reach out if you have any questions
16 replies
PPrisma
Created by Cyrus on 4/23/2024 in #help-and-questions
prisma accelerate + custom directory
No description
35 replies