Endpoint
URL Pattern:/graphql/{branch_name}
Examples:
/graphql/main- Main branch/graphql/feature-network-updates- Feature branch
Making Requests
HTTP POST
Send GraphQL queries via HTTP POST with JSON body:With Variables
With Operation Name
Time-Travel Queries
Query historical data using theat query parameter:
-30m- 30 minutes ago-1h- 1 hour ago-7d- 7 days ago
at parameter. Infrahub automatically resets at to the current time for mutation operations.
Branch Operations
Query from a Branch
Specify the branch in the URL path:Mutations on Branches
All mutations automatically target the branch specified in the URL:Real-Time Subscriptions
GraphQL subscriptions enable real-time updates over WebSocket connections.WebSocket Connection
URL Pattern:ws://localhost:8000/graphql/{branch_name}
Subscriptions use the graphql-ws protocol:
Subscription Protocol Messages
Client → Server:connection_init- Initialize connectionstart- Start subscriptionstop- Stop subscriptionconnection_terminate- Close connection
connection_ack- Connection acknowledgeddata- Subscription dataerror- Error occurredcomplete- Subscription completed
Schema Introspection
Get Schema
Query the GraphQL schema using introspection:Get Type Information
Common Query Patterns
List All Objects
Filter by Attribute
Nested Relationships
Pagination
Common Mutations
Create Object
Update Object
Delete Object
Upsert Object
Response Format
Successful Query
Query with Errors
Partial Success
Performance Optimization
Query Depth and Height
Infrahub tracks query complexity metrics:- Depth: Maximum nesting level of the query
- Height: Total number of fields requested
/home/daytona/workspace/source/backend/infrahub/graphql/app.py:281 for metric implementation.
Field Selection
Only request fields you need:Use Pagination
Always use pagination for large datasets:Metrics and Monitoring
Infrahub exposes Prometheus metrics for GraphQL operations:graphql_duration- Query execution timegraphql_query_depth- Query depth distributiongraphql_query_height- Query height distributiongraphql_query_errors- Error countgraphql_response_size- Response size in bytesgraphql_query_objects- Number of impacted models
/home/daytona/workspace/source/backend/infrahub/graphql/metrics.py for implementation.
Error Codes
Common GraphQL error codes:NODE_NOT_FOUND- Requested node doesn’t existPERMISSION_DENIED- Insufficient permissionsVALIDATION_ERROR- Input validation failedCONSTRAINT_VIOLATION- Uniqueness or other constraint violatedBRANCH_NOT_FOUND- Specified branch doesn’t exist