-
Notifications
You must be signed in to change notification settings - Fork 118
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
Nexus with Prisma 2 doesn't support Multiple DB Connections #992
Comments
This issue is related to another: #835 The parameter config for prismaClient only supports one client. The render of index.d.ts in @ types>typegen-nexus-plugin-prisma has only support for one client: https://github.com/graphql-nexus/nexus-plugin-prisma/blob/main/src/typegen/render.ts#L56 Those items above, I think, would be somewhat easy to support, but the problem I see is how we would know which Prisma client to use for which model? As far as I see in the nexus:src/definitions/objectType.ts -- there's not much work with for existing code. I doubt main owners of nexus core would want to update this just for Prisma Plugin. We could have another config param that is part of prismaClient where we state types as a child array of each prisma clients. Not sure this is good. If two or more clients have the same model name? |
A smelly solution could be the hijacking of description param in objectType with some sort of meta syntax to state which client to use. |
Seems like you could just wrap all the Types in different client names. Or append something to the front of of each type to mach the DB name. There's many solutions. I am now using multiple clients through merge schema. |
How does merged schema work with different db contexts? |
I'm using the Nexus-Prisma-Plugin, that outputs a schema, so I then create a second file structure with the second client and merge them together. I think it would be better to combine in one client, but it works. My only questions is whether or not I will be able to connect two different DBs together where relationships exist and I will find that out shortly. I can't share the code, but if you want to document it for other to use I could show you what I did and probably make a simple version to share some time in the future. |
Don't you lose the type-sense without using the types>typegen-nexus-plugin-prisma output in node_modules? The whole idea of nexus using t.model.param is tied to this as I understand it. |
No, it all works, you just have a file for each client that outputs all the generated types. It's pretty hard to explain without a code example. I will see if I can can put something together. |
I was able to connect to multiple DBs with Prisma 1 and Nexus, but just creating multiple clients and then merging them all into the schema, however I haven't figure out a way to do this with Prisma 2 and Nexus.
This is a huge issue for how my company is using Nexus. Has anyone figured out a work around for this?
The text was updated successfully, but these errors were encountered: