2.4.2 ⢠Published 4 years ago
@prisma-multi-tenant/redwood v2.4.2
đ§ Add multi-tenancy to your Redwood application
Installation
yarn global add prisma-multi-tenant # CLI for tenant management
yarn add @prisma-multi-tenant/redwood # Redwood plugin
cp api/
prisma-multi-tenant init # Init multi-tenancy in your Redwood project
Usage
â ď¸ First, make sure you followed the Prisma-multi-tenant Getting Started Guide. â ď¸
First, replace the code in api/src/lib/db.js
with the following:
import { MultiTenant, fromContext } from '@prisma-multi-tenant/redwood'
export const multiTenant = new MultiTenant()
export const db = fromContext()
Then, update the code in api/src/functions/graphql.js
:
import { multiTenant } from 'src/lib/db'
export const handler = createGraphQLHandler({
schema: makeMergedSchema({
schemas,
services: makeServices({ services }),
}),
context: async ({ event }) => ({
// The name can come from anywhere (headers, token, ...)
db: await multiTenant
.get('dev') // or 'my_tenant_A' or anything
.catch(console.error),
}),
})
Finally, restart the server:
yarn redwood dev
Example
Check out an example application using Redwood and the multi-tenant plugin here.
Documentation
Read more on how prisma-multi-tenant
can help you achieve multi-tenancy for your apps:
- ⨠Getting Started â¨
- Complete documentation
- How to integrate with:
- Examples
- Basic (JS)
- Basic (TS)
- Express
- Apollo
- Blitz
- Redwood
- Bison (TODO)
- Issues with Vercel
- Contributing guide
Author
đ¤ Thibaud Courtoison
- Twitter: @Errorname_
- Github: @Errorname
- Prisma's Slack: @Errorname
đ¤ Contributors
Contributions, issues, and feature requests are welcome! đ
Feel free to check issues page.
Show your support
Give a âď¸ if this project helped you!
đ License
Copyright Š 2020 Thibaud Courtoison.
This project is MIT licensed.