Class MaxQueryComplexityInstrumentation

  • All Implemented Interfaces:
    Instrumentation

    @PublicApi
    public class MaxQueryComplexityInstrumentation
    extends SimplePerformantInstrumentation
    Prevents execution if the query complexity is greater than the specified maxComplexity.

    Use the Function<QueryComplexityInfo, Boolean> parameter to supply a function to perform a custom action when the max complexity is exceeded. If the function returns true a AbortExecutionException is thrown.

    • Constructor Detail

      • MaxQueryComplexityInstrumentation

        public MaxQueryComplexityInstrumentation​(int maxComplexity)
        new Instrumentation with default complexity calculator which is `1 + childComplexity`
        Parameters:
        maxComplexity - max allowed complexity, otherwise execution will be aborted
      • MaxQueryComplexityInstrumentation

        public MaxQueryComplexityInstrumentation​(int maxComplexity,
                                                 java.util.function.Function<QueryComplexityInfo,​java.lang.Boolean> maxQueryComplexityExceededFunction)
        new Instrumentation with default complexity calculator which is `1 + childComplexity`
        Parameters:
        maxComplexity - max allowed complexity, otherwise execution will be aborted
        maxQueryComplexityExceededFunction - the function to perform when the max complexity is exceeded
      • MaxQueryComplexityInstrumentation

        public MaxQueryComplexityInstrumentation​(int maxComplexity,
                                                 FieldComplexityCalculator fieldComplexityCalculator)
        new Instrumentation with custom complexity calculator
        Parameters:
        maxComplexity - max allowed complexity, otherwise execution will be aborted
        fieldComplexityCalculator - custom complexity calculator
      • MaxQueryComplexityInstrumentation

        public MaxQueryComplexityInstrumentation​(int maxComplexity,
                                                 FieldComplexityCalculator fieldComplexityCalculator,
                                                 java.util.function.Function<QueryComplexityInfo,​java.lang.Boolean> maxQueryComplexityExceededFunction)
        new Instrumentation with custom complexity calculator
        Parameters:
        maxComplexity - max allowed complexity, otherwise execution will be aborted
        fieldComplexityCalculator - custom complexity calculator
        maxQueryComplexityExceededFunction - the function to perform when the max complexity is exceeded