WithTenant
Interface for multi-tenant entities
Audience: Programmer
The WithTenant interface is implemented by entities that support multi-tenancy, allowing data isolation between different organizations or tenants.
Fields
tenantID
ID!
Unique identifier of the tenant
tenant
Tenant
Reference to the tenant entity
Multi-Tenancy in pyck
pyck provides built-in multi-tenancy support where:
Data is automatically filtered by tenant
Queries only return data for the current tenant
Mutations validate tenant ownership
Cross-tenant queries require special permissions
Implementing Types
Most core entities implement WithTenant:
InventoryItem
Customer
Supplier
Repository
PickingOrder
ReceivingInbound
Usage
Security
Tenant isolation is enforced at the API layer
Users can only access their tenant's data
Admin users may have cross-tenant access
Tenant ID is extracted from JWT token
Best Practices
Never expose tenant IDs to end users
Validate tenant ownership in mutations
Use tenant-specific caching
Consider tenant-specific configurations
Plan for data migration between tenants
See Also
Authentication - How tenant context is established
Node Interface - Base interface for entities
Last updated
Was this helpful?
