Closed greeksolid closed 11 months ago
See https://github.com/47ng/prisma-field-encryption/issues/63#issuecomment-1641637805, there's a beta release for Prisma v5 with the client extension mechanism.
Please give it a try and let me know if it works for you so I can merge PR #66 which includes this change.
Yes, it works perfectly fine on my end and also passes type checking with the 'as PrismaClient' cast. Thanks!
If you're only using the extension mechanism, this cast should not be needed, could you confirm that it works without please?
It's only needed in the integration tests of this library to account for both mechanism being used by the same test codebase.
In my project it seems that the cast is required. I 'll try to reproduce it in a barebones project and get back to you.
For reference, I've opened a bug report in the Prisma repository about typing extended clients, see https://github.com/prisma/prisma/issues/20326
Sorry man false alarm! I am using Next.js and initialize the client like this, so I had
globalForPrisma.prisma explicitly typed as PrismaClient | undefined
.
I changed it to this and get no type errors anymore.
import { PrismaClient } from "@prisma/client";
import { fieldEncryptionExtension } from "prisma-field-encryption";
const createPrismaClient = () => {
const globalClient = new PrismaClient({
log: ["warn", "query", "error"],
});
return globalClient.$extends(fieldEncryptionExtension());
};
const globalForPrisma = globalThis as unknown as {
prisma: ReturnType<typeof createPrismaClient> | undefined;
};
export const prisma = globalForPrisma.prisma ?? createPrismaClient();
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
Released in 1.5.0.
Would it be possible to update the peerDependencies to include latest @prisma/client release or is there a breaking change?