Skip to content

appany/AppAny.HotChocolate.FluentValidation

Repository files navigation

AppAny.HotChocolate.FluentValidation

Nuget Hotchocolate | FluentValidation

Input field HotChocolate + FluentValidation integration

Disclaimer

This library is a rework of internal package inside @appany

Usage

# 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) { ... }

Docs

Benchmarks

About

Input field HotChocolate GraphQL + FluentValidation integration

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages