@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<ExecutionResult> |
beginExecuteOperation(InstrumentationExecuteOperationParameters instrumentationExecuteOperationParameters)
This is called just before the execution of the query operation is started.
|
InstrumentationContext<java.util.List<ValidationError>> |
beginValidation(InstrumentationValidationParameters parameters)
This is called just before the parsed query document is validated.
|
InstrumentationState |
createState(InstrumentationCreateStateParameters parameters)
This will be called just before execution to create an object that is given back to all instrumentation methods
to allow them to have per execution request state
|
protected AbortExecutionException |
mkAbortException(int totalComplexity,
int maxComplexity)
Called to generate your own error message or custom exception class
|
beginExecution, beginExecutionStrategy, beginField, beginFieldFetch, beginParse
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
beginExecuteOperation, beginExecution, beginExecutionStrategy, beginField, beginFieldComplete, beginFieldComplete, beginFieldFetch, beginFieldListComplete, beginFieldListComplete, beginParse, beginSubscribedFieldEvent, beginSubscribedFieldEvent, beginValidation, createState, instrumentDataFetcher, instrumentDataFetcher, instrumentDocumentAndVariables, instrumentDocumentAndVariables, instrumentExecutionContext, instrumentExecutionContext, instrumentExecutionInput, instrumentExecutionInput, instrumentExecutionResult, instrumentExecutionResult, instrumentSchema, instrumentSchema
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 InstrumentationState createState(InstrumentationCreateStateParameters parameters)
Instrumentation
parameters
- the parameters to this steppublic 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 endspublic InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters instrumentationExecuteOperationParameters)
Instrumentation
beginExecuteOperation
in interface Instrumentation
beginExecuteOperation
in class SimpleInstrumentation
instrumentationExecuteOperationParameters
- 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