Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for custom prisma locations #31

Closed
kokokenada opened this issue Aug 22, 2022 · 6 comments
Closed

Support for custom prisma locations #31

kokokenada opened this issue Aug 22, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@kokokenada
Copy link

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.

@ryan-s-singh
Copy link

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

@fuergaosi233
Copy link

I have the same problem

@fuergaosi233
Copy link

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"
      ]
    },
...

@marcjulian
Copy link
Member

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.

@marcjulian marcjulian added the enhancement New feature or request label Sep 27, 2022
@hotrungnhan
Copy link

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.

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

marcjulian added a commit that referenced this issue Nov 22, 2022
* provide PrismaClient instance
@marcjulian
Copy link
Member

marcjulian commented Nov 22, 2022

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.

marcjulian added a commit that referenced this issue Jan 16, 2023
* add custom prisma service, #31

* provide PrismaClient instance

* 0.20.0-dev.1

* add forRootAsync for custom prisma module

* inject prisma client into custom prisma service
* add useFactory/useClass to forRootAsync

* 0.20.0-dev.2

* add custom location and extension docs

* add extension example

* add extensions example and docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants