Skip to main content
Version: 0.3.x (0.3.0)

Class ValueObjectRequestExecutorBuilderExtensions

Namespace: AdCodicem.ValueObjects.HotChocolate
Assembly: AdCodicem.ValueObjects.HotChocolate.dll

Maps value objects to GraphQL scalars of their own in a HotChocolate schema, read through their rules.

public static class ValueObjectRequestExecutorBuilderExtensions

Inheritance​

object ← ValueObjectRequestExecutorBuilderExtensions

Inherited Members​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Methods​

AddValueObjectScalar<TSelf, TValue>(IRequestExecutorBuilder, string?)​

Maps one value object to its scalar, closed at compile time: a construction of a generic value object, or one written by hand, under native AOT.

public static IRequestExecutorBuilder AddValueObjectScalar<TSelf, TValue>(this IRequestExecutorBuilder builder, string? name = null) where TSelf : struct, IValueObject<TSelf, TValue>

Parameters​

builder IRequestExecutorBuilder

The schema's builder.

name string?

The name of the scalar, a GraphQL name, or null to take the one gives, or else the schema's naming conventions.

Returns​

IRequestExecutorBuilder

builder, so calls can be chained.

Type Parameters​

TSelf

The value object type.

TValue

Its underlying type.

Remarks​

The scalar binds implicitly to TSelf, so that the schema uses it wherever the type appears, beside or without it. It needs no registration of the value object: its rules are read through TSelf, never through the registry.

Exceptions​

ArgumentNullException

builder is null.

ArgumentException

name is empty or white space.

AddValueObjects(IRequestExecutorBuilder, Action<ValueObjectScalarOptions>?)​

Maps every value object the schema meets to a scalar of its own, which reads a value through the type's rules.

public static IRequestExecutorBuilder AddValueObjects(this IRequestExecutorBuilder builder, Action<ValueObjectScalarOptions>? configure = null)

Parameters​

builder IRequestExecutorBuilder

The schema's builder, from AddGraphQL() or AddGraphQLServer().

configure Action<ValueObjectScalarOptions>?

Names, specifications and messages of the scalars, or null for none.

Returns​

IRequestExecutorBuilder

builder, so calls can be chained.

Remarks​

A type discovery handler, asked before HotChocolate's own, answers each value object the schema references, as an argument, an input field, a field or the element of a list, with a closed over it through the descriptor's visitor. A TSelf? is the nullable scalar. A value object the registry holds is closed at compile time; one it does not hold yet, a construction of a generic value object or a value object written by hand, is described by ValueObjectRegistry.TryResolve where the runtime supports dynamic code, and refused with a naming ValueObjectRegistry.Register and where it does not, as under native AOT.

Every call on one schema configures the same , in the order of the calls, and the schema gets one handler. A scalar adds wins for its type.

The first call also adds an error filter, which localizes a refusal under , quoting the scalar's name for a value refused in an argument or an input field selects.

Exceptions​

ArgumentNullException

builder is null.