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
Multiple prisma with nx workspaces and nestjs #7470
Comments
@ionut-gheorghe I'm having the same problem here with a project using Nx and Prisma. My use-case is to have a monorepo using Nx with multiple micro services. I would like to use a separate Prisma client with its own schema in every micro service. |
Could be related to #7439 |
@3dmind Could you maybe open your own issue about this and explain your full use case, maybe even create a minimal reproduction of what you are trying to do and how it fails? We are super interested in making Prisma Client work with mono repos of course, but need more input. @ionut-gheorghe Did this work before or did you just hit this problem when trying to use Prisma? |
What do you mean by if it worked before. Current I use nestjs with multiple prisma's but it is not a monorepo, its the standard structure. I have the prisma's folders (each folder is a differrent database) at the root level of the project and I reference them from the code. When deploying I just copy prisma's folders along side with node_modules, dist and package.json. |
Sorry for not being clear, I wanted to know if you did the same thing with an earlier Prisma version and if it worked there - or if you are just now trying to change your project structure and are hitting this problem. This seems to be the case. |
I can reproduce the behaviour with I don't have any experience with Nx so I can't really assess this but I will mark this as confirmed bug so that someone else can have a look. |
Hi bro, did you solve this problem? |
Hi all, I found a temporary solution for this case: For schema file:
and then, in nest module file, you can import client like that
If you find a better solution, remember to be brave and share it like I did. lol :D |
@BetterLuke Hi 👋 I tested your solution and it works. |
@3dmind @BetterLuke @janpio @pantharshit00 This issue is caused by webpack bundling the prisma-generated .js files and trying to resolve the node internal modules. Your should be able to fix this by configuring webpack:
|
Hey everyone, I just have used the reproduction with |
So what is the actual solution to this issue? Do we (developers) do something on our side or is it fixed with Prisma by default? |
You can try the current (If the |
What's exactly the solution to this? What do developers have to do to achieve different Prisma setups for each microservice (app)? |
@exsesx : the idea is as follows. Maybe you want to have everything that is related to one particular feature of your app (i.e., In this case, you would also want to have the specific Hope this helps?! |
Thanks @johannesschobel My end goal is to have separate microservices with their schema, connections strings, and maybe even different databases. I'll dig into it more to see if any of the above works. |
Dear @exsesx please note, that the current state of my library does not support generating multiple All the best |
That'd be fantastic, thanks 👍🏻 |
Dear @exsesx , try the latest version of |
For microservices in a monorepo, I believe the best is to generate in a custom |
@millsp yeah, but you still need multiple schema files (i.e. one per service). And that is what my library solves. All the best |
@johannesschobel I'm very interested in prismerge, even if it is a workaround (my solution support a kind of microservices where each service has a prisma schema but uses the same physical database as per the other services ) I find prismerge very interesting. Unfortunately, there is ZERO docs about usage and how to integrate into "microservices" oriented architecture. Where it is possible to find some examples? |
Dear @hoghweed , i think, this may be a very specific use-case that you describe here. I use I believe, however, that Can you describe, what All the best, |
Bug description
I have tried nx workspace with nestjs and prisma which outputs to node_modules (default setup) and it works, but using multiple prismas with custom directory output fails.
Running
nx build
shows warningsRunning
nx serve
shows errorsI have this kind of setup with nestjs and many prisma (need to access different databases) using the default structure (no monorepo) and it works without problems. I think the problem resides with webpack and the binaries from prisma, but I don't know how to solve it.
nx structure
How to reproduce
npm install
npm run prisma1:generate
scriptnpm run prisma2:generate
scriptnx serve
Expected behavior
To run without errors
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: