I am working on a multi-tenant SAAS application using efcore and graphql using hot chocolate as graphql server, where each tenant can define some custom fields/columns.
For instance, a tenant can add a column Email in customer entity, while another tenant can add another column like Phone in customer entity. On database side, the Customer table will have a pre-defined schema and an extra column named CustomFields. The CustomField column will have jsonb data-type (postgres database) and will store the extra columns added by tenant in json object.
Tenant1 -> Customer.CustomField {"Email": "xxx@.com"}
Tenant2 -> Customer.CustomField {"Phone": "xxx-xxx-xxxx"}
The json document can contain any number of properties. My objective is to expose these properties as individual fields in GraphQL schema.
I reviewed extending-types, and tried to read the json document and dynamically create the new fields and append to Customer type. However, I can't make it work and dynamically add new dynamic properties as .
At this point not sure which of the following or any of these can be used
- Dynamic schema
- Schema Stiching
- Extended types.