blitz-js / blitz

⚡️ The Missing Fullstack Toolkit for Next.js
https://Blitzjs.com
MIT License
13.61k stars 795 forks source link

Prisma Accelerate #4251

Open madhenry opened 10 months ago

madhenry commented 10 months ago

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

cfragkos commented 8 months ago

Any progress on this?

flybayer commented 8 months ago

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

papsavas commented 7 months ago

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(...)