@PublicApi public class MaxQueryComplexityInstrumentation extends SimpleInstrumentation
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.INSTANCE
Constructor and Description |
---|
MaxQueryComplexityInstrumentation(int maxComplexity)
new Instrumentation with default complexity calculator which is `1 + childComplexity`
|
MaxQueryComplexityInstrumentation(int maxComplexity,
FieldComplexityCalculator fieldComplexityCalculator)
new Instrumentation with custom complexity calculator
|
MaxQueryComplexityInstrumentation(int maxComplexity,
FieldComplexityCalculator fieldComplexityCalculator,
java.util.function.Function<QueryComplexityInfo,java.lang.Boolean> maxQueryComplexityExceededFunction)
new Instrumentation with custom complexity calculator
|
MaxQueryComplexityInstrumentation(int maxComplexity,
java.util.function.Function<QueryComplexityInfo,java.lang.Boolean> maxQueryComplexityExceededFunction)
new Instrumentation with default complexity calculator which is `1 + childComplexity`
|
Modifier and Type | Method and Description |
---|---|
InstrumentationContext<java.util.List<ValidationError>> |
beginValidation(InstrumentationValidationParameters parameters)
This is called just before the parsed query document is validated.
|
protected AbortExecutionException |
mkAbortException(int totalComplexity,
int maxComplexity)
Called to generate your own error message or custom exception class
|
beginExecuteOperation, beginExecution, beginExecutionStrategy, beginField, beginFieldComplete, beginFieldFetch, beginFieldListComplete, beginParse, createState, instrumentDataFetcher, instrumentExecutionContext, instrumentExecutionResult, instrumentSchema
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
beginSubscribedFieldEvent, createState, instrumentDocumentAndVariables, instrumentExecutionInput
public MaxQueryComplexityInstrumentation(int maxComplexity)
maxComplexity
- max allowed complexity, otherwise execution will be abortedpublic MaxQueryComplexityInstrumentation(int maxComplexity, java.util.function.Function<QueryComplexityInfo,java.lang.Boolean> maxQueryComplexityExceededFunction)
maxComplexity
- max allowed complexity, otherwise execution will be abortedmaxQueryComplexityExceededFunction
- the function to perform when the max complexity is exceededpublic MaxQueryComplexityInstrumentation(int maxComplexity, FieldComplexityCalculator fieldComplexityCalculator)
maxComplexity
- max allowed complexity, otherwise execution will be abortedfieldComplexityCalculator
- custom complexity calculatorpublic MaxQueryComplexityInstrumentation(int maxComplexity, FieldComplexityCalculator fieldComplexityCalculator, java.util.function.Function<QueryComplexityInfo,java.lang.Boolean> maxQueryComplexityExceededFunction)
maxComplexity
- max allowed complexity, otherwise execution will be abortedfieldComplexityCalculator
- custom complexity calculatormaxQueryComplexityExceededFunction
- the function to perform when the max complexity is exceededpublic InstrumentationContext<java.util.List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters)
Instrumentation
beginValidation
in interface Instrumentation
beginValidation
in class SimpleInstrumentation
parameters
- the parameters to this stepInstrumentationContext
object that will be called back when the step endsprotected AbortExecutionException mkAbortException(int totalComplexity, int maxComplexity)
totalComplexity
- the complexity of the querymaxComplexity
- the maximum complexity allowed