blitz icon indicating copy to clipboard operation
blitz copied to clipboard

Prisma Accelerate

Open madhenry opened this issue 1 year ago • 3 comments

What do you want and why?

I want to migrate my blitz app from previous Prisma Data Proxy to the new Accelerate product but extending prisma + enhancePrisma + blitz-server AuthServerPlugin PrismaStorage types don't play well together

Possible implementation(s)

import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'
import { enhancePrisma } from 'blitz'

const EnhancedPrisma = enhancePrisma(PrismaClient)

export default new EnhancedPrisma().$extends(withAccelerate())

This breaks all db collection types in tsc and using it without enhancePrisma just breaks the types in PrismaStorage(db)

export const { gSSP, gSP, api } = setupBlitzServer({
  plugins: [
    AuthServerPlugin({
      ...authConfig,
      storage: PrismaStorage(db),
      ...
    }),
   ],
  ...
})

Additional context

Latest blitz version

CleanShot 2023-11-10 at 14 23 17@2x

madhenry avatar Nov 10 '23 12:11 madhenry

Any progress on this?

cfragkos avatar Jan 16 '24 08:01 cfragkos

We'll take a PR for this, otherwise you can just use Prisma without the enhancePrisma() wrapper.

flybayer avatar Jan 16 '24 15:01 flybayer

otherwise you can just use Prisma without the enhancePrisma() wrapper.

Not really the case, Prisma errors to image when using PrismaClient although its only used on the server.

Error is solved when you remove .$extends(...)

papsavas avatar Jan 25 '24 10:01 papsavas