blitz-js / blitz-js/blitz

Prisma Accelerate

Open
#4,251 3 comments 3 reactions 0 assignees View on GitHub
status/ready-to-work-on
Dominant language
TypeScript
Stars
14.1k
Forks
803
PR merge metrics
No merged PRs in 30d

Description

### 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)

```ts
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)

```ts
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](https://github.com/blitz-js/blitz/assets/434217/38d8b590-3e3b-4d4c-9ac3-3576700a07ff)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the TypeScript errors with enhancePrisma, the Prisma Accelerate extension, and PrismaStorage(db) in the setup shown. Trace the types used by enhancePrisma, AuthServerPlugin, and PrismaStorage; done means an Accelerate-extended client works with PrismaStorage without breaking database collection types.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, typescript
Domain
authentication, backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.