我正在使用Prisma和Yoga GraphQL为多租户数据库设置后端env
为了管理多租户,我们选择使用Prisma Server的"env“(dev/prod/prod)来处理它。没关系,Prisma服务器并不难管理,现在我们为每个租户提供了一个端点,如:http://localhost:4466/service/tenant/
之后,使用graphql模式从Prisma中提取*.graphql是很容易的.
但是现在的困难是:如何为我需要的服务和租户设置一个GraphQL服务器?
基于不同的外部/ tuto / docs /.我没有找到在我的GraphQL中设置index.js服务器的方法:侦听多个URI,并且每个URI都连接了一个prisma服务器。
例如,我需要:
GraphQL服务器端点
http://localhost:4000/service-1/client-1/只能是请求http://localhost:4466/service-1/client-1/对于client-2(第二个租户),http://localhost:4000/service-1/client-2/只能是请求http://localhost:4466/service-1/client-2/
GraphQL服务器似乎每个端口只能启动一次(在这里4000)
在这里编辑一个代码来演示https://github.com/mouchimotte/prisma-yoga-multitenancy
发布于 2019-01-16 15:27:38
正如@rma在评论中所说,您可以使用prisma-多租户 npm包构建多租户应用程序。
您可以阅读这篇解释如何使其工作的文章:https://medium.zenika.com/building-a-multi-tenant-application-with-prisma-11bf890304d6
发布于 2022-02-03 20:17:57
如果您希望使用共享数据库策略,即一个带有租户ID列的数据库,则可以使用以下包:https://www.npmjs.com/package/node-express-multitenant
https://stackoverflow.com/questions/52151398
复制相似问题