yoga graphql server + prisma server : multitenancy

Viewed 927

I'm setting up a backend env for multi-tenancy database using Prisma Server and Yoga GraphQL

To manage multi-tenancy, we choose to handle it by using the "env" (dev/stage/prod) of Prisma Server. It's OK, Prisma server was not difficult to manage and now we have an endpoint for each tenant like: http://localhost:4466/service/tenant/

After that, it was easy to extract *.graphql from Prisma using graphql get-schema.

But now, the difficulty is: how to set up a GraphQL Server for as many as service I need and tenant ?

Based on different exmample / tuto / docs / ... I don't find the way to set up GraphQL Server in my index.js to say: listen on multiple URI and each URI have one prisma server connected.

Example, I need:

GraphQL Server endpoint http://localhost:4000/service-1/client-1/ can be only request http://localhost:4466/service-1/client-1/

and for client-2 (second tenant) http://localhost:4000/service-1/client-2/ can be only request http://localhost:4466/service-1/client-2/

GraphQL Server seems can be started only one time per port (here 4000)

[EDIT] Here a code to illustrate https://github.com/mouchimotte/prisma-yoga-multitenancy

2 Answers
Related