Accessing extended operations on the prisma client with typescript
I'm trying to make some abstract types around the Prisma Client, like so:
But the issue I'm facing is when I try to access any operation that has been extended on the client. For example, I have this
prisma-bark-extension
on the Prisma Client. When I use prisma.modelName.operation
, I see the additional actions provided by the middleware, but import type { Operation } from "@prisma/client/runtime/library";
does not contain a list of them.
Would anyone have an idea on how I can get the extended list of operations?3 Replies
Defube Custom Op:
Extend Types:
Example Usage:
I tried to achieve a similar result by simply getting the
keyof Database[M]
as the list of operations, and this indeed does work. But it fails when it tries to match the types with Prisma.Args, Payload or Result (which is the main use-case).Similar errors when trying out your solution by creating a union of operation types as well.