You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Prisma introduces the concept of “Extensions”, which enable the insertion of custom business logic before a query is sent to the database.
On paper, this idea is fantastic, as it opens doors to various functionalities such as “soft deletes,” “custom identifiers,” “row-level logging,” and more.
However, the current implementation of Prisma extensions faces a significant challenge: they fail to parse nested queries, as exemplified by the following code snippet:
awaitdb.user.create({data: {name: “John”,memberships: {create: {// Nested create here, which won’t be parsed by the extension(…)}}}})
This limitation poses a problem because many scenarios cannot afford to parse only the top-level queries. For instance, imagine a logging system that doesn’t log nested queries or a soft-delete system that hard deletes nested queries 😅
Consequently, people are not utilizing extensions.
Describe the solution you'd like.
Given that ZenStack already parses Prisma queries to enforce access policies, and that the Prisma team doesn't seem to prioritize this issue, I believe it would be an ideal place to propose a new and safer approach to extensions.
We could envision a simple API, quite similar to the Prisma Extensions API, that would allow us to define custom logic for specific events, such as “create” for a “User” entity. For example:
constdb=enhance(prisma,…).$on(“create”,“User”,(args,query)=>{// (…) Custom logic here to modify ‘args’returnquery(args)})
I've seen this idea mentioned in the past, I wanted to open this issue as a way to deeply explore all the intricacies of this idea, possibly leading to an implementation.
Is your feature request related to a problem? Please describe.
Prisma introduces the concept of “Extensions”, which enable the insertion of custom business logic before a query is sent to the database.
On paper, this idea is fantastic, as it opens doors to various functionalities such as “soft deletes,” “custom identifiers,” “row-level logging,” and more.
However, the current implementation of Prisma extensions faces a significant challenge: they fail to parse nested queries, as exemplified by the following code snippet:
This limitation poses a problem because many scenarios cannot afford to parse only the top-level queries. For instance, imagine a logging system that doesn’t log nested queries or a soft-delete system that hard deletes nested queries 😅
Consequently, people are not utilizing extensions.
Describe the solution you'd like.
Given that ZenStack already parses Prisma queries to enforce access policies, and that the Prisma team doesn't seem to prioritize this issue, I believe it would be an ideal place to propose a new and safer approach to extensions.
We could envision a simple API, quite similar to the Prisma Extensions API, that would allow us to define custom logic for specific events, such as “create” for a “User” entity. For example:
I've seen this idea mentioned in the past, I wanted to open this issue as a way to deeply explore all the intricacies of this idea, possibly leading to an implementation.
Additional context.
References: #20554
The text was updated successfully, but these errors were encountered: