Class ValueObjectScalarType<TSelf, TValue>
Namespace: AdCodicem.ValueObjects.HotChocolate
Assembly: AdCodicem.ValueObjects.HotChocolate.dll
A value object as a GraphQL scalar of its own, whose literal is its underlying value's.
public sealed class ValueObjectScalarType<TSelf, TValue> : ScalarType, IScalarTypeDefinition, ISyntaxNodeProvider<ScalarTypeDefinitionNode>, ILeafType, IInputTypeDefinition, IInputType, IOutputTypeDefinition, ITypeDefinition, INameProvider, IDescriptionProvider, IDirectivesProvider, IFeatureProvider, ISyntaxNodeProvider, ISchemaCoordinateProvider, IRuntimeTypeProvider, IOutputType, IType, ITypeSystemMember, IEquatable<IType> where TSelf : struct, IValueObject<TSelf, TValue>
Type Parameters
TSelf
The value object type.
TValue
Its underlying type.
Inheritance
object ← TypeSystemObject ← TypeSystemObject<ScalarTypeConfiguration> ← ScalarType ← ValueObjectScalarType<TSelf, TValue>
Implements
IScalarTypeDefinition, ISyntaxNodeProvider<ScalarTypeDefinitionNode>, ILeafType, IInputTypeDefinition, IInputType, IOutputTypeDefinition, ITypeDefinition, INameProvider, IDescriptionProvider, IDirectivesProvider, IFeatureProvider, ISyntaxNodeProvider, ISchemaCoordinateProvider, IRuntimeTypeProvider, IOutputType, IType, ITypeSystemMember, IEquatable<IType>
Inherited Members
ScalarType.IsAssignableFrom(ITypeDefinition), ScalarType.Equals(IType?), ScalarType.IsValueCompatible(IValueNode), ScalarType.IsValueCompatible(JsonElement), ScalarType.CoerceInputLiteral(IValueNode), ScalarType.CoerceInputValue(JsonElement, IFeatureProvider), ScalarType.CoerceOutputValue(object, ResultElement), ScalarType.ValueToLiteral(object), ScalarType.InputValueToLiteral(JsonElement, IFeatureProvider), ScalarType.ToString(), ScalarType.ToSyntaxNode(), ScalarType.Kind, ScalarType.Bind, ScalarType.RuntimeType, ScalarType.Coordinate, ScalarType.SpecifiedBy, ScalarType.SerializationType, ScalarType.Pattern, ScalarType.Directives, TypeSystemObject<ScalarTypeConfiguration>.Features, TypeSystemObject.Scope, TypeSystemObject.Name, TypeSystemObject.Description, TypeSystemObject.Features, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
A value object over a TSelf.TryParse in the invariant culture, its normalizer included.
A number is read exactly as the underlying type, then goes through TSelf.TryCreate.
A value the type refuses is answered with a extensions.code, the rule's code; the exception carries the code in
its Exception is a
A value is written as its underlying value, never through a formatting hook of the value object. An uninitialized instance, equal to the default, whose value the type refuses is never written, nor is a real that is not finite.
The description is the type's, from its schema. The pattern it declares, or the one the wire form of a duration, a
time of day or a @serializeAs under ApplySerializeAsToScalars. GraphQL has no place for a length, a bound
or a known value.
Properties
RuntimeType
The .NET type representation of this scalar.
public override Type RuntimeType { get; }
Property Value
SerializationType
Gets the possible types that this scalar can serialize to.
public override ScalarSerializationType SerializationType { get; }
Property Value
ScalarSerializationType
Methods
CoerceInputLiteral(IValueNode)
Coerces a GraphQL literal (AST value node) into a runtime value.
public override object CoerceInputLiteral(IValueNode valueLiteral)
Parameters
valueLiteral IValueNode
The GraphQL literal to coerce.
Returns
Returns the runtime value representation.
Exceptions
valueLiteral is null.
LeafCoercionException
Unable to coerce the given valueLiteral into a runtime value.
CoerceInputValue(JsonElement, IFeatureProvider)
Coerces an external input value (deserialized JSON) into a runtime value.
public override object CoerceInputValue(JsonElement inputValue, IFeatureProvider context)
Parameters
inputValue JsonElement
The deserialized JSON input value to coerce.
context IFeatureProvider
Provides access to the coercion context.
Returns
Returns the runtime value representation.
Exceptions
LeafCoercionException
Unable to coerce the given inputValue into a runtime value.
CoerceOutputValue(object, ResultElement)
Coerces a runtime value into an external output representation and writes it to the result.
public override void CoerceOutputValue(object runtimeValue, ResultElement resultValue)
Parameters
runtimeValue object
The runtime value to coerce. Must not be null; null handling
is the responsibility of the caller.
resultValue ResultElement
The result element to write the output value to.
Exceptions
runtimeValue is null.
LeafCoercionException
Unable to coerce the given runtimeValue into an output value.
CreateConfiguration(ITypeDiscoveryContext)
protected override ScalarTypeConfiguration CreateConfiguration(ITypeDiscoveryContext context)
Parameters
context ITypeDiscoveryContext
Returns
ScalarTypeConfiguration
ValueToLiteral(object)
Converts a runtime value into a GraphQL literal (AST value node). Used for default value representation in SDL and introspection.
public override IValueNode ValueToLiteral(object runtimeValue)
Parameters
runtimeValue object
The runtime value to convert. Must not be null; null handling
is the responsibility of the caller.
Returns
IValueNode
Returns a GraphQL literal representation of the runtime value.
Exceptions
runtimeValue is null.
LeafCoercionException
Unable to convert the given runtimeValue into a literal.