How to infer prisma types from multiple projects?

Viewed 56

I have a project that is structured as follows

dashboard
 -- prisma-project-1
 -- prisma-project-2
 -- client-of-prisma-project-1-and-prisma-project-2

It is a dashboard meant to combine data from two databases and represent them in some way. I then proceed to import the clients of prisma-project-1 and prisma-project-2 in client-of-prisma-project-1-and-prisma-project-2.

However, when I import prisma clients in prisma-project-1 in client-of-prisma-project-1-and-prisma-project-2, the prisma types are those from prisma-project-2.

How do I import prisma clients in prisma-project-1 and prisma-project-2 in client-of-prisma-project-1-and-prisma-project-2without their types overriding each other?

1 Answers

You could explicitly specify locations where PrismaClient and Types of each prisma project should be generated.

Setting the location in a custom output path should resolve this.

Example:

generator client {
  provider = "prisma-client-js"
  output   = "../src/generated/client"
}

Import statement would look like:

import { PrismaClient } from './generated/client'
Related