Skip to content

Commit

Permalink
Reuse the Prisma client type when wrapping it by using withPgAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
exAspArk committed Feb 21, 2024
1 parent fb39d15 commit 839043f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const WRITE_OPERATIONS = ["create", "update", "upsert", "delete", "createMany",
const EXECUTE_OPERATIONS = ["$executeRaw", "$executeRawUnsafe"]
const ASYNC_LOCAL_STORAGE = new AsyncLocalStorage();

export const withPgAdapter = (originalPrisma: any) => {
const { logQueries } = originalPrisma._engineConfig
export const withPgAdapter = <PrismaClientType>(originalPrisma: PrismaClientType): PrismaClientType => {
const { logQueries } = (originalPrisma as any)._engineConfig

const prisma = originalPrisma.$extends({
const prisma = (originalPrisma as any).$extends({
query: {
async $allOperations({ args, query, operation }: any) {
// Not contextualizable query
Expand Down Expand Up @@ -56,7 +56,7 @@ export const withPgAdapter = (originalPrisma: any) => {
prisma._engineConfig.logQueries = false
prisma._engineConfig.adapter = bindAdapter(pgAdapter);

return prisma
return prisma as PrismaClientType
}

export const setContext = (callback: (req: Request) => any) => {
Expand Down

0 comments on commit 839043f

Please # to comment.