@prisma-multi-tenant/redwood
v2.4.2
Published
Redwood plugin for prisma-multi-tenant
Downloads
2
Maintainers
Readme
🧭 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.