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

Field
Type
Description

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

  1. Never expose tenant IDs to end users

  2. Validate tenant ownership in mutations

  3. Use tenant-specific caching

  4. Consider tenant-specific configurations

  5. Plan for data migration between tenants

See Also

Last updated

Was this helpful?