nestjs-query icon indicating copy to clipboard operation
nestjs-query copied to clipboard

Prisma Integration

Open rulim34 opened this issue 1 year ago • 5 comments

Prisma is an open source next-generation ORM. Currently, it is not officially integrated with the nestjs-query package. It would be nice and easier for developer to use if we could get some official integration.

Have you read the Contributing Guidelines?

Yes

Describe the solution you'd like Integration for Prisma ORM

Additional context Ofcourse I don't expect full integration in one night. But a small start would be very nice. I'm not know much thing yet, but I'm happy to help if u need it.

rulim34 avatar Apr 23 '23 12:04 rulim34

Could be interesting to add! But to much work for myself as I also don't use / have a project using Prisma.

TriPSs avatar Jul 17 '23 13:07 TriPSs

We were willing to tackle building a Prisma adapter for Nestjs-Query so deeply looked into this. The bottom line is that it's just not possible with Prisma as it stands. The generated code does not emit the metadata needed at runtime in order to enable such an adapter. We ended up rolling a Prisma code generator to generate TypeORM definitions based on our Prisma schema. It wasn't pretty, but it saves us from having to write hundreds of entity classes and keeps up with ongoing changes a lot easier.

dvins avatar Nov 19 '23 08:11 dvins

Interesting @dvins, I myself now also started using Prisma in a project and wonder: would something basic not work if we only go based on the metadata nestjs-query itself collects for relations?

I think the non relations should not be an issue right? Since you would already need to decorate each field.

We could also, if more info is needed expose @Field/@FilterableField ect from the Prisma adapter package so we can add additional fields the adapter could handle it correctly.

TriPSs avatar Jan 03 '24 21:01 TriPSs

I've been spending on time on this topic, currently using nestjs-prisma-generator instead. In my past experience, creating an abstract for prisma its rather hard because the generated types from the client is particular to the schema, and there isn't a low-level generic exposed.

There is multiple issues/community thread in prisma are tracking this as well. All end up using some form of generator to read prisma schema and generate boilerplate code instead.

darr1s avatar Mar 20 '24 14:03 darr1s

I've been spending on time on this topic, currently using nestjs-prisma-generator instead. In my past experience, creating an abstract for prisma its rather hard because the generated types from the client is particular to the schema, and there isn't a low-level generic exposed.

There is multiple issues/community thread in prisma are tracking this as well. All end up using some form of generator to read prisma schema and generate boilerplate code instead.

Spot on, the metadata (outside of the Prisma schema) just does not exist to do this.

dvins avatar Mar 20 '24 16:03 dvins