Reference

UseTraxOperatorConsoleDocuments

Package Trax.Api.DashboardNamespace Trax.Api.Dashboard.ExtensionsSource ApiDashboardEndpointExtensions.cs

Registers the documents the operations console sends, the same ones UseTraxApiDashboard registers, without serving the dashboard. It is for a host that requires persisted operations and that operators reach only from a terminal, with trax-console. A host that serves the dashboard needs no call to it.

using Trax.Api.Dashboard.Extensions;
using Trax.Api.GraphQL.Extensions;
using Trax.Api.GraphQL.PersistedOperations.Extensions;
 
builder.Services.AddTraxGraphQL(graphql => graphql
    .ExposeOperationQueries()
    .ExposeOperationMutations()
    .GateOperations(roles: "Operator")
    .UsePersistedOperations(po => po.RequirePersisted(true)));
 
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
app.UseTraxGraphQL();
app.UseTraxOperatorConsoleDocuments();

Signature

public static IEndpointRouteBuilder UseTraxOperatorConsoleDocuments(this IEndpointRouteBuilder endpoints)

It returns endpoints, for chaining.

Behavior

  • What it registers. The console's documents, embedded in the package, each under trax_console_<name>_<hash> when the host starts, as UseTraxApiDashboard does (Trax.Api ADR 0042). A document the host cannot serve is left out and logged.
  • What it does not change. Who may run them. Every request is still decided by the operations gate (GateOperations(...) or GateOperationsToAuthenticatedUsers()), or, for a stream (onTrainStateChanged, onDataChanged, onJunctionEvent, onMachineInstanceChanged), by its per-subscriber authorization, which delivers each event only to a caller who may see it. No page, route or anonymous access is added.
  • Without persisted operations nothing is registered, and a frontend sends the documents' text.
  • Call it before the host starts. Calling it again, or beside UseTraxApiDashboard, registers each document once. A call after the host has started and registered its persisted documents throws, since the documents would never be registered.

Exceptions

ExceptionWhen
InvalidOperationExceptionAddTraxGraphQL() was not called, or does not expose the operations namespace (ExposeOperationQueries()).
InvalidOperationExceptionThe host has already started and registered its persisted documents.