Understanding Relationships
Relationship Types
Infrahub supports different relationship types:Attribute Relationships
Attribute Relationships
Core relationships that define the structure of an object. These are required for the object’s identity.Example: A Device’s
location attributeGeneric Relationships
Generic Relationships
Optional connections between objects that don’t define the object’s core identity.Example: A Device’s
tags relationshipCardinality
Relationships can have different cardinalities:- One: Single related object (e.g., Device → Location)
- Many: Multiple related objects (e.g., Device → Tags)
Working with Single Relationships
Create with Relationship
Create an object with a single relationship:Query with Relationship
Fetch an object and its related data:Update Relationship
Change a single relationship:Using Relationship IDs
Access Relationship Properties
Working with Many Relationships
Create with Multiple Relationships
Create an object with many related objects:Query Many Relationships
Fetch objects with multiple related items:Add to Many Relationship
Add new items to an existing relationship:Remove from Many Relationship
Remove specific items:Replace All Related Objects
Clear All Related Objects
Nested Relationships
Query Nested Relationships
Fetch relationships of related objects:Traverse Relationships
Navigate through multiple levels:Bidirectional Relationships
Access Reverse Relationships
Update from Both Sides
Relationship Filters
Filter Related Objects
Count Related Objects
Check for Specific Relationship
Relationship Validation
Validate Relationships Exist
Validate Relationship Constraints
Bulk Relationship Operations
Update Relationships for Multiple Objects
Add Tag to Multiple Objects
Batch Relationship Updates
Advanced Patterns
Relationship Builder
Relationship Graph Traversal
Next Steps
Branches
Work with Git-like branches
Batch Operations
Perform efficient bulk operations
Error Handling
Handle relationship errors
Async Operations
Use async patterns effectively