GraphQL Subscriptions
GraphQL subscriptions provide real-time updates to connected clients via the Apollo Server subscription transport.
Available Subscriptions
| Subscription | Filter | Payload |
|---|---|---|
taskUpdated(taskId: ID!) |
By task ID | Updated AgentTask |
insightCreated |
All for tenant | New Insight |
recommendationCreated |
All for tenant | New Recommendation |
scenarioCompleted(scenarioId: ID) |
Optional by scenario | Completed ScenarioRun |
guidanceCreated(customerId: ID) |
Optional by customer | New GuidanceItem |
creditProposalCreated |
All for tenant | New CreditLineProposal |
Usage
Subscriptions are accessed via the same /graphql endpoint using the WebSocket transport protocol (graphql-ws).
Example subscription:
subscription {
recommendationCreated {
id
type
priority
confidence
description
requiresApproval
customerId
createdAt
}
}
Example with filter:
subscription {
taskUpdated(taskId: "task-uuid") {
id
status
currentStepIndex
totalSteps
result
error
}
}
Authentication
Subscriptions require the same authentication as queries and mutations. The JWT or session token is provided during the WebSocket connection initialization.
Event Sources
Subscription events are triggered by internal event bus activity. When a service publishes a domain event (e.g., nba.generated), the API Gateway's subscription resolver broadcasts it to connected clients whose tenant context matches.
All subscriptions enforce tenant isolation — clients only receive events for their own tenant.
Implemented in services/api-gateway/src/schema.ts at commit 4b572c2.