graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

role-based schema prefix for multi-tenancy apps

Open tom-pryor opened this issue 5 years ago • 18 comments

Hi, we're currently exploring ways to add a GraphQL API to our existing SaaS multi tenant application. We currently use postgres schemas to isolate our clients and each client has identical tables, etc. in their schema. For example

myapp (database)

  • client1 (schema)
    • users (table)
    • products (table)
  • client2 (schema)
    • users (table)
    • products (table)

All tenants share the same code base and the code simply does a SET search_path <name> to select the schema based of the subdomain, e.g client1.myapp.com.

Hasura looks amazing but we're not really sure how we can replicate this functionality as it seems to fail at the first hurdle. When we go to track our existing tables it's populating them with the tenant name (e.g client1_users, should just be users) and we're not sure how to perform this transparent schema switching.

Is there any way we can accomplish this with Hasura? We'd really love to use this project!

tom-pryor avatar Dec 31 '19 02:12 tom-pryor