public static IValidationBuilder AddValidationRule <T>( this IValidationBuilder builder) where T : DocumentValidatorVisitor, new() { return(builder.ConfigureValidation(m => m.Modifiers.Add(o => o.Rules.Add(new DocumentValidatorRule <T>(new T()))))); }
public static IValidationBuilder AddValidationRule <T>( this IValidationBuilder builder, Func <IServiceProvider, ValidationOptions, T> factory) where T : DocumentValidatorVisitor { return(builder.ConfigureValidation((s, m) => m.Modifiers.Add(o => o.Rules.Add(new DocumentValidatorRule <T>(factory(s, o)))))); }
/// <summary> /// GraphQL execution will only consider the executable definitions /// Operation and Fragment. /// /// Type system definitions and extensions are not executable, /// and are not considered during execution. /// /// To avoid ambiguity, a document containing TypeSystemDefinition /// is invalid for execution. /// /// GraphQL documents not intended to be directly executed may /// include TypeSystemDefinition. /// /// http://spec.graphql.org/June2018/#sec-Executable-Definitions /// </summary> public static IValidationBuilder AddDocumentRules( this IValidationBuilder builder) { return(builder.ConfigureValidation( m => m.Modifiers.Add(o => { if (o.Rules.All(t => t.GetType() != typeof(DocumentRule))) { o.Rules.Add(new DocumentRule()); } }))); }
public static IValidationBuilder TryAddValidationRule <T>( this IValidationBuilder builder) where T : class, IDocumentValidatorRule, new() { return(builder.ConfigureValidation(m => m.Modifiers.Add(o => { if (o.Rules.All(t => t.GetType() != typeof(T))) { o.Rules.Add(new T()); } }))); }
public static IValidationBuilder TryAddValidationVisitor <T>( this IValidationBuilder builder, bool isCacheable = true) where T : DocumentValidatorVisitor, new() { return(builder.ConfigureValidation(m => m.Modifiers.Add(o => { if (o.Rules.All(t => t.GetType() != typeof(DocumentValidatorRule <T>))) { o.Rules.Add(new DocumentValidatorRule <T>(new T(), isCacheable)); } }))); }
public static IValidationBuilder TryAddValidationRule <T>( this IValidationBuilder builder, Func <IServiceProvider, ValidationOptions, T> factory) where T : DocumentValidatorVisitor { return(builder.ConfigureValidation((s, m) => m.Modifiers.Add(o => { if (o.Rules.All(t => t.GetType() != typeof(DocumentValidatorRule <T>))) { o.Rules.Add(new DocumentValidatorRule <T>(factory(s, o))); } }))); }
/// <summary> /// Sets the maximum allowed depth of a query. The default /// value is <see langword="null"/>. The minimum allowed value is /// <c>1</c>. /// </summary> internal static IValidationBuilder SetAllowedExecutionDepth( this IValidationBuilder builder, int allowedExecutionDepth) { if (allowedExecutionDepth < 1) { throw new ArgumentOutOfRangeException( nameof(allowedExecutionDepth), allowedExecutionDepth, Resources.HotChocolateValidationBuilderExtensions_MinimumAllowedValue); } return(builder.ConfigureValidation(m => m.Modifiers.Add(o => o.MaxAllowedExecutionDepth = allowedExecutionDepth))); }
public static IValidationBuilder TryAddValidationRule <T>( this IValidationBuilder builder, Func <IServiceProvider, ValidationOptions, T> factory) where T : class, IDocumentValidatorRule { return(builder.ConfigureValidation((s, m) => m.Modifiers.Add(o => { T instance = factory(s, o); if (o.Rules.All(t => t.GetType() != instance.GetType())) { o.Rules.Add(instance); } }))); }
/// <summary> /// GraphQL execution will only consider the executable definitions /// Operation and Fragment. /// /// Type system definitions and extensions are not executable, /// and are not considered during execution. /// /// To avoid ambiguity, a document containing TypeSystemDefinition /// is invalid for execution. /// /// GraphQL documents not intended to be directly executed may /// include TypeSystemDefinition. /// /// http://spec.graphql.org/June2018/#sec-Executable-Definitions /// </summary> public static IValidationBuilder AddDocumentRules( this IValidationBuilder builder) { return(builder.ConfigureValidation( m => m.Modifiers.Add(o => o.Rules.Add(new DocumentRule())))); }
internal static IValidationBuilder SetAllowedComplexity( this IValidationBuilder builder, int allowedComplexity) => builder.ConfigureValidation(m => m.Modifiers.Add(o => o.MaxAllowedComplexity = allowedComplexity));
internal static IValidationBuilder UseMultipliers( this IValidationBuilder builder, bool useMultipliers) => builder.ConfigureValidation(m => m.Modifiers.Add(o => o.UseComplexityMultipliers = useMultipliers));
public static IValidationBuilder SetComplexityCalculation( this IValidationBuilder builder, ComplexityCalculation calculation) => builder.ConfigureValidation(m => m.Modifiers.Add(o => o.ComplexityCalculation = calculation));
internal static IValidationBuilder SetAllowedExecutionDepth( this IValidationBuilder builder, int allowedExecutionDepth) => builder.ConfigureValidation(m => m.Modifiers.Add(o => o.MaxAllowedExecutionDepth = allowedExecutionDepth));