GraphQL Client

Reference for Trax.Api.GraphQL.Client, the outbound client that validates hand-written queries against a server's schema and runs them, and for Trax.Api.GraphQL.Client.Trax, which adds an in-process schema source and startup validation. For the concepts (query modes, schema providers, keyed clients), see GraphQL Client.

services
    .AddTraxGraphQLClient(new Uri("https://api.example.com/graphql"))
    .UseFileSchema("schema.graphql")
    .WithStrictness(ResponseStrictness.ThrowOnDrift);
 
// Later, from DI:
var player = await executor.Run(new GetPlayerRequest { Id = "p-1" }, cancellationToken);

Pages

PageDescription
AddTraxGraphQLClientRegisters a client against one endpoint and returns its builder
AddKeyedTraxGraphQLClientRegisters a client under a DI key, for talking to several servers
TraxGraphQLClientBuilderSchema source, strictness, HTTP client, JSON options, startup validation
ValidateGraphQLClientAssembliesAsyncValidates every request type in a set of assemblies against the schema
IGraphQLClientRequestThe request contract, IGraphQLClientExecutor.Run, and the exceptions it throws
GraphQLResourceRequestBase class for requests whose query is an embedded .graphql file
ResponseStrictnessHow strictly a response is checked against the request's response type

Packages

dotnet add package Trax.Api.GraphQL.Client
dotnet add package Trax.Api.GraphQL.Client.Trax   # UseAssemblySchema, UseStartupValidation
dotnet add package Trax.Api.GraphQL.Client.Typed  # TypedRequest (POCO-derived queries)

The kernel package has no dependency on trains, the mediator or a database, so any .NET application can use it.