Hello! What is currently the best way to communica...
# orm-help
b
Hello! What is currently the best way to communicate with a secondary prisma service? Scenario: I want to build multiple services and have them all use the same auth service. I want my public schema to hide the fact there are two services and present itself as a single service. Here is a mockup of my schema:
Copy code
type Query {
  posts: [Post]
}
type Post {
  # this type is stored in my primary service
  text: String
  author: User!
}
type User {
  # this type is stored in the primary service too
  id: ID! @unique
  posts: [Post]
  accountId: ID! @unique
  account: Account!
}
type Account {
  # this type is stored in my secondary service
  id: ID! @unique
  username: String!
}
j
I believe the cleanest option happens to also be the most simple option! Your "public" GraphQL schema should include resolvers which rely on two separate instances of the Prisma client, each of which points at a different Prisma Server. It is trivial to instantiate a new instance of Prisma Client: https://www.prisma.io/docs/1.26/prisma-client/setup/constructor-TYPESCRIPT-rsc5/
I presume you have a division in mind for what exactly the two Prisma services are in your use case, but just to illustrate the point: you might have one Client instance in the variable
authService
which points to a service at
<https://prisma.myapp.com/auth>
and the other under
userContentService
which points at
<https://prisma.myapp.com/content>
.
b
I am pretty sure the prisma client is generated per service? Meaning a prisma client generated from my
content
service would fail if I created a new instance pointing to my
auth
service?
I have submitted a feature request [here](https://github.com/prisma/prisma/issues/4047)