Support for custom prisma locations
kokokenada opened this issue ยท 6 comments
I have an issue with monorepo using npm workspaces and prisma. The set up is there are two microservices that both use prisma (say packages/api1, packages/api2). If the same version of prisma is used in each, npm will create https://github.com/prisma in the root node_modules. The generated .prisma files are installed as a sibling to https://github.com/prisma, so api1 and api2 can clobber each other. One can specify where to generate the files (https://www.prisma.io/docs/concepts/components/prisma-client/working-with-prismaclient/generating-prisma-client#using-a-custom-output-path), however, nestjs uses @prisma/client to import, so the new location is ignored.
Not using a mono repo but ran into a use case for this due to the checksum check issue if you are on a network cant reach it. that prisma has and figured this could be a good solution to that
I have the same problem
I solved this problem by using the path capability of tsconfig
// schema.prisma
generator client {
provider = "prisma-client-js"
output = "../src/generated/prisma-client"
}
// tsconfig.json
...
"paths": {
"@prisma/client": [
"./src/generated/prisma-client"
]
},
...
Hi @kokokenada this would be a great feature to support custom prisma locations.
PrismaService
is extended by PrismaClient
, hence an import statement is required and @prisma/client
is used. I am not aware that the import for extends can be dynamically changed.
Thanks @fuergaosi233 for a solution!
I will think about how to solve this feature request.
Hi @kokokenada this would be a great feature to support custom prisma locations.
PrismaService
is extended byPrismaClient
, hence an import statement is required and@prisma/client
is used. I am not aware that the import for extends can be dynamically changed.Thanks @fuergaosi233 for a solution!
I will think about how to solve this feature request.
not working now. I set the paths too, it still loading from @prisma/client true path, and throw out the error
Prisma : 4.6.1
Please checkout my solution for custom prisma locations #40.
This also allows to import multiple PrismaClients if needed.
I am happy to hear your feedback if this covers your use cases and works fine in your projects.