GraphQL API
Trax exposes a GraphQL endpoint powered by HotChocolate. It provides queries for inspecting trains, manifests, manifest groups, and executions, mutations for queuing/running trains and managing the scheduler, and real-time subscriptions for train lifecycle events via WebSocket.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTrax(trax => trax
.AddEffects(effects => effects.UsePostgres(connectionString))
.AddMediator(typeof(Program).Assembly)
);
builder.Services.AddTraxGraphQL(); // Requires AddTrax() first — throws InvalidOperationException otherwise
var app = builder.Build();
app.UseTraxGraphQL(); // default: /trax/graphql (named schema — won't conflict with your own)
app.Run();Navigate to the endpoint URL in a browser to open Banana Cake Pop, the built-in GraphQL IDE. It provides schema exploration, autocompletion, and query execution without any extra tooling.
Pages
| Page | Description |
|---|---|
| AddTraxGraphQL | Registration and endpoint mapping |
| TraxQuery & TraxMutation Attributes | Opt trains into the typed GraphQL schema with [TraxQuery] or [TraxMutation] |
| Queries | health, trains, manifests, manifest, manifestGroups, executions, execution |
| Mutations | Grouped into dispatch (auto-generated train mutations) and operations (scheduler control mutations) |
| Subscriptions | Real-time WebSocket events for train lifecycle transitions (onTrainStarted, onTrainCompleted, onTrainFailed, onTrainCancelled) |
| TraxBroadcast Attribute | Opt trains into subscription events with [TraxBroadcast] |
Package
dotnet add package Trax.Api.GraphQL