Skip to content

Prisma Integration #4195

@clayrisser

Description

@clayrisser

This issue is for sharing thoughts on using prisma with loopback 4.

I wrote a simple example using prisma with loopback 4 and below are my initial observations.

  1. Prisma does not work well with repositories, datasources or modals. The main reason for this is because prisma modals are tightly coupled with prisma datasources. This creates real friction with repositories, since repositories depend on a modal and datasource. I found it made the most sense to just directly use prisma in my controllers. The downside to this is that you cannot create loopback repository relationships with prisma data. Honestly though, that responsibility probably should lie with prisma anyways if you choose to use it.

  2. The prisma api gets generated from prisma modals, which I find a bit awkward, although I understand it makes it easier to deal with the types. This will create challenges with loopbacks type system because loopback will be unaware of prisma types. This might be able to be improved with some hackery.

You can look at my example below.

https://github.com/codejamninja/lb4-prisma/blob/master/example/src/controllers/user.controller.ts

Metadata

Metadata

Assignees

Labels

RepositoryIssues related to @loopback/repository packagefeature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions