47ng / 47ng/prisma-field-encryption
Documenting Typing the Extended PrismaClient
- Lenguaje dominante
- TypeScript
- Estrellas
- 306
- Forks
- 40
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I've been running into an issue where the VSCode Typescript errors with errors like the following:
```
Excessive stack depth comparing types...
```
```
This expression is not callable....
```
After searching and consulting with various AI oracles I realized the issue could be solved by removing the prisma-field-encryption extension. This Github issue was a hint, although the discussion is from when clientExtensions were a preview feature.
https://github.com/prisma/prisma/issues/17236
The solution seems to be the following:
```typescript
import { PrismaClient } from '@prisma/client'
import { fieldEncryptionExtension } from 'prisma-field-encryption'
import { type PrismaClientExtends } from '@prisma/client/extension'
import type * as runtime from '@prisma/client/runtime/library'
// Define the extended client type using Prisma's extension type system
type ExtendedClient = PrismaClient & PrismaClientExtends
const globalClient = new PrismaClient()
export const client = globalClient.$extends(
// This is a function, don't forget to call it:
fieldEncryptionExtension()
) as ExtendedClient
export type { ExtendedClient as PrismaClient }
```
Does this fix make sense? It is working nicely for me. If so I'd like to open a PR to add this to the Readme. 🙏
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.