Infrahub supports GraphQL subscriptions for real-time event streaming over WebSocket connections. Subscribe to changes and events as they happen.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/OpsMill/infrahub/llms.txt
Use this file to discover all available pages before exploring further.
Subscription Endpoint
Subscriptions use the GraphQL WebSocket protocol:Available Subscriptions
Infrahub currently provides a single subscription type for querying events:Query Subscription
Subscribe to events with optional filtering and polling interval.Name identifier for the subscription
Polling interval in milliseconds (default: 1000)
Optional parameters to filter events. Structure depends on the event type being subscribed to.
Event Types
Subscriptions can receive various event types from Infrahub:Branch Events
Listen for branch-related events:BranchCreatedEvent- A new branch was createdBranchDeletedEvent- A branch was deletedBranchMergedEvent- A branch was mergedBranchRebasedEvent- A branch was rebased
Artifact Events
Subscribe to artifact generation and updates:artifact_definition_id- The artifact definition IDchecksum- Current checksum of the artifactchecksum_previous- Previous checksumstorage_id- Current storage location IDstorage_id_previous- Previous storage locationbranch- Branch where the event occurredevent- Event nameoccurred_at- Timestamp of the event
Repository Events
Monitor Git repository synchronization:RepositorySyncEvent- Repository sync started or completedRepositoryCommitEvent- New commits detected
Using Subscriptions
With GraphQL Client Libraries
Most GraphQL client libraries support subscriptions over WebSocket:Apollo Client (JavaScript/TypeScript)
Python with gql
WebSocket Protocol
Subscriptions follow the graphql-ws protocol:- Connection Init: Send authentication
- Subscribe: Send subscription query
- Next: Receive events as they occur
- Complete: Close subscription
Event Structure
All events implement theEventNodeInterface:
Unique event ID
Event type name
Branch where the event occurred
Timestamp when the event occurred
Account ID that triggered the event
Event hierarchy level (0 for root events)
Parent event ID for nested events
Whether this event has child events
Primary Infrahub node this event is associated with
Related Infrahub nodes for this event
Filtering Events
Use theparams argument to filter subscribed events:
Branch Filter
Custom Parameters
Different event types support different filter parameters. Check the event type documentation for available filters.Best Practices
Set Appropriate Intervals
Balance real-time needs with server load:Handle Reconnections
Always implement reconnection logic in your client:Clean Up Subscriptions
Unsubscribe when no longer needed:Limitations
- Subscriptions require WebSocket support
- Authentication tokens must be valid for the entire subscription duration
- Maximum concurrent subscriptions per client may be limited by server configuration
- Events are delivered at the specified interval, not immediately
Example: Full Subscription Handler
See Also
- Queries - Query data from Infrahub
- Mutations - Modify data in Infrahub
- WebSocket Protocol - graphql-ws specification