What are Resource Hierarchies?
Resource hierarchies allow you to model parent-child relationships between resources. A folder contains documents, a project contains tasks, an order contains line items. These relationships enable hierarchical permission propagation and structured queries.Hierarchy Edge Properties
| Property | Type | Description |
|---|---|---|
parentResourceId | string | The parent resource |
childResourceId | string | The child resource |
relationshipType | string? | Type of relationship (e.g., “contains”, “references”) |
cascade | CascadeModeEnum | Permission inheritance: inherit or none |
createdAt | string | When the relationship was created |
Cascade Modes
Thecascade property controls how permissions propagate through the hierarchy:
Inherit
Permissions on the parent automatically apply to the child:cascade: "inherit":
- If a user can read the folder, they can read documents inside
- Permissions flow down the hierarchy automatically
- Ideal for folder/document, project/task relationships
None
No permission inheritance—child resources require explicit access:cascade: "none":
- Parent access does not grant child access
- Each resource requires its own permissions
- Ideal for references, links, dependencies
Creating Resource Hierarchies
Resource Type Hierarchies
Before creating resource hierarchies, define which resource types can contain which:Hierarchical Permission Patterns
Pattern 1: Folder Access Grants Document Access
When a user can access a folder, they can access its contents:Pattern 2: Inherited Permissions
Define permissions that propagate through the hierarchy:Common Hierarchy Patterns
Document Management
Project Management
E-Commerce
Construction
Querying Hierarchies
Relationship Types
UserelationshipType to distinguish different kinds of relationships:
| Type | Use Case |
|---|---|
contains | Parent physically contains child (folder → document) |
references | Parent references child (issue → linked issue) |
owns | Parent owns child (user → created documents) |
depends-on | Parent depends on child (task → blocking task) |
Best Practices
Define type hierarchies first
Define type hierarchies first
Always define resource type hierarchies before creating resource instance hierarchies.
Use meaningful relationship types
Use meaningful relationship types
Choose relationship types that reflect your domain model.
Avoid deep nesting
Avoid deep nesting
Very deep hierarchies can impact query performance. Consider flattening when possible.
Consider permission implications
Consider permission implications
Plan how permissions will propagate through your hierarchy before building it.
Ancestor Traversal
When evaluating permissions withcascade: "inherit", the engine traverses ancestors: