public int Visit( DocumentNode node, ISchema schema, ComplexityCalculation calculateComplexity) { if (node == null) { throw new ArgumentNullException(nameof(node)); } if (schema == null) { throw new ArgumentNullException(nameof(schema)); } if (calculateComplexity == null) { throw new ArgumentNullException( nameof(calculateComplexity)); } var context = MaxComplexityVisitorContext .New(schema, calculateComplexity); Visit(node, context); return(context.MaxComplexity); }
public MaxComplexityRule( IValidateQueryOptionsAccessor options, ComplexityCalculation calculateComplexity) { _options = options ?? throw new ArgumentNullException(nameof(options)); _calculateComplexity = calculateComplexity ?? DefaultComplexity; }
internal protected MaxComplexityWithMultipliersVisitorContext( ISchema schema, IVariableCollection variables, ComplexityCalculation calculateComplexity) : base(schema, calculateComplexity) { _variables = variables; }
public MaxComplexityMiddleware( QueryDelegate next, IValidateQueryOptionsAccessor options, ComplexityCalculation complexityCalculation) { _next = next ?? throw new ArgumentNullException(nameof(next)); _options = options ?? throw new ArgumentNullException(nameof(options)); _calculation = complexityCalculation ?? DefaultComplexity; }
protected MaxComplexityVisitorContext( MaxComplexityVisitorContext context) { Schema = context.Schema; FragmentPath = context.FragmentPath; FieldPath = context.FieldPath; Fragments = context.Fragments; TypeContext = context.TypeContext; _calculateComplexity = context._calculateComplexity; _root = context._root; Scope = context.Scope; }
protected MaxComplexityVisitorContext( ISchema schema, ComplexityCalculation calculateComplexity) { _calculateComplexity = calculateComplexity; Schema = schema; FragmentPath = ImmutableHashSet <string> .Empty; FieldPath = ImmutableList <IOutputField> .Empty; Fragments = new Dictionary <string, FragmentDefinitionNode>(); _root = this; Scope = this; }
protected MaxComplexityVisitorContext( ImmutableHashSet <string> fragmentPath, ImmutableList <IOutputField> fieldPath, MaxComplexityVisitorContext context) { FragmentPath = fragmentPath; FieldPath = fieldPath; Schema = context.Schema; Fragments = context.Fragments; TypeContext = context.TypeContext; _calculateComplexity = context._calculateComplexity; _root = context._root; Scope = context.Scope; }
public static IQueryExecutionBuilder AddComplexityCalculation( this IQueryExecutionBuilder builder, ComplexityCalculation complexityCalculation) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (complexityCalculation == null) { throw new ArgumentNullException(nameof(complexityCalculation)); } builder.Services.AddSingleton <ComplexityCalculation>( complexityCalculation); return(builder); }
public static IValidationBuilder SetComplexityCalculation( this IValidationBuilder builder, ComplexityCalculation calculation) => builder.ConfigureValidation(m => m.Modifiers.Add(o => o.ComplexityCalculation = calculation));