Reference

UseAssemblySchema

Package Trax.Api.GraphQL.Client.TraxNamespace Trax.Api.GraphQL.Client.TraxSource TraxBuilderExtensions.cs, AssemblySchemaProvider.cs

Replaces the client's schema provider with AssemblySchemaProvider, which builds the server's HotChocolate schema in-process from the server's own configuration delegate. Declared on the static class TraxBuilderExtensions.

Signature

public static TraxGraphQLClientBuilder UseAssemblySchema(
    this TraxGraphQLClientBuilder builder,
    Action<IRequestExecutorBuilder> configureSchema)

Parameters

ParameterTypeRequiredDescription
builderTraxGraphQLClientBuilderYesThe client's builder
configureSchemaAction<IRequestExecutorBuilder>YesConfigures a HotChocolate request executor the way the server's Program.cs does

Returns

The same TraxGraphQLClientBuilder.

Behavior

  • Throws ArgumentNullException when either argument is null.
  • On the first schema request the provider runs configureSchema against a fresh services.AddGraphQL(), builds the executor, prints its schema to SDL and builds the validator's schema from that. No network call is made. A failure throws GraphQLSchemaIntrospectionException carrying the generated SDL.
  • The subscription type is dropped when the client's RemoveSubscriptionsFromSchema is true, the default.
  • The calling process takes a binary dependency on the assembly that defines configureSchema.
  • As with the other schema methods, the last one called on a builder decides the provider.

Example

services
    .AddTraxGraphQLClient(new Uri("https://players.example.com/graphql"))
    .UseAssemblySchema(PlayerSchema.Configure)
    .UseStartupValidation(typeof(Program).Assembly);

See also