Multiple prisma clients - many databases
See original GitHub issueIn code
export function getPrismaFromContext(context: any) {
const prismaClient = context.prisma;
if (!prismaClient) {
throw new Error("Unable to find Prisma Client in GraphQL context. Please provide it under the `context.prisma` key.");
}
return prismaClient;
}
there is a fixed “prisma” key, but If we would add parametrization of this name in the config, then we would be able to use it with many databases that have their own clients in context.
Probably we need extend this cod by new option with default value “prisma”:
export interface ExternalGeneratorOptions {
emitDMMF?: boolean;
emitTranspiledCode?: boolean;
simpleResolvers?: boolean;
useOriginalMapping?: boolean;
useUncheckedScalarInputs?: boolean;
emitIdAsIDType?: boolean;
emitOnly?: EmitBlockKind[];
customPrismaImportPath?: string;
}
then add this param to function generateHelpersFile
and replace “prisma” by this parameter in
export function getPrismaFromContext(context: any) {
const prismaClient = context.prisma;
if (!prismaClient) {
throw new Error("Unable to find Prisma Client in GraphQL context. Please provide it under the `context.prisma` key.");
}
return prismaClient;
}
Issue Analytics
- State:
- Created a year ago
- Comments:16 (6 by maintainers)
Top Results From Across the Web
How to use Prisma with multiple database schemas
Many database providers allow you to organize database tables into named groups. ... query across multiple database schemas with Prisma Client ...
Read more >Multiple Connections / Databases / Datasources #2443 - GitHub
I'm using multiple schema files in production right now for many projects. Prisma client works fine, you just import from wherever you set...
Read more >I want to use multiple database in prisma orm - Stack Overflow
prisma in separate folders and initialise PrismaClient for each schema.prisma that will point to the specific database. Share.
Read more >Multiple Prisma Clients, One App - zach.codes
Multiple Prisma Clients, One App. There are times where you need to connect to multiple databases within a single backend server.
Read more >How to connect Multiple Databases using Prisma in Nest JS
You can use multiple databases with Prisma by creating different schema files and generating separate Prisma clients for each database. References: github link ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I modified the generator and it seems to be working fine. I don’t know if there is a hidden problem.
Conflict between declared prisma context key and runtime prisma clients in graphql context