Documenting Typing the Extended PrismaClient
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 75/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Domain
- documentation
Research direction
The issue is about adding a TypeScript typing example to the README. Look at the existing README file to see where the usage examples are placed. The provided code snippet shows how to type an extended PrismaClient with the field encryption extension. Verify the snippet works by checking the current extension API in the source code, then update the documentation accordingly.
Written by the indexing model from the issue text.
Description
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:
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<runtime.Types.Extensions.DefaultArgs>
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. 🙏
- Dominant language
- TypeScript
- Stars
- 307
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from 47ng/prisma-field-encryption
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
47ng/prisma-field-encryption#106 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
47ng/prisma-field-encryption#75 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
47ng/prisma-field-encryption#152 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
47ng/prisma-field-encryption#143 · 7 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
47ng/prisma-field-encryption#142 · 9 comments · 3 reactions ·
All issues in 47ng/prisma-field-encryption
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100