Input field HotChocolate
+ FluentValidation
integration
This library is a rework of internal package inside @appany
# Basic
services.AddGraphQLServer()
.AddFluentValidation();
descriptor.Field(x => x.Example(default!))
// Explicit over implicit preferred, you have to add .UseFluentValidation() to all arguments requiring validation
.Argument("input", argument => argument.UseFluentValidation());
... Example([UseFluentValidation] ExampleInput input) { ... }
# Customizations
services.AddGraphQLServer()
.AddFluentValidation(options =>
{
options.SkipValidation(...)
.UseErrorMappers(...)
.UseInputValidatorProviders(...);
});
descriptor.Field(x => x.Example(default!))
.Argument("input", argument => argument.UseFluentValidation(options =>
{
options.SkipValidation(...)
.UseErrorMappers(...)
.UseInputValidatorProviders(...)
.UseValidator<ExampleInputValidator>()
.UseValidator<ExampleInput, ExampleInputValidator>()
.UseValidator<ExampleInput, ExampleInputValidator>(strategy =>
{
strategy.IncludeProperties(input => input.ExampleProperty);
// ...
});
}));
... Example([UseFluentValidation(typeof(ExampleInputValidator))] ExampleInput input) { ... }
- Abstractions
- Features
- Defaults
- Examples