@PublicApi public class MaxQueryComplexityInstrumentation extends SimplePerformantInstrumentation
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.
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 |
|---|---|
@Nullable InstrumentationContext<ExecutionResult> |
beginExecuteOperation(InstrumentationExecuteOperationParameters instrumentationExecuteOperationParameters,
InstrumentationState rawState)
This is called just before the execution of the query operation is started.
|
@Nullable InstrumentationContext<java.util.List<ValidationError>> |
beginValidation(InstrumentationValidationParameters parameters,
InstrumentationState rawState)
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
|
beginExecuteOperation, beginExecution, beginExecution, beginExecutionStrategy, beginExecutionStrategy, beginField, beginField, beginFieldComplete, beginFieldComplete, beginFieldFetch, beginFieldFetch, beginFieldListComplete, beginFieldListComplete, beginParse, beginParse, beginSubscribedFieldEvent, beginSubscribedFieldEvent, beginValidation, createState, instrumentDataFetcher, instrumentDataFetcher, instrumentDocumentAndVariables, instrumentDocumentAndVariables, instrumentExecutionContext, instrumentExecutionContext, instrumentExecutionInput, instrumentExecutionInput, instrumentExecutionResult, instrumentExecutionResult, instrumentSchema, instrumentSchemapublic 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)
InstrumentationcreateState in interface InstrumentationcreateState in class SimplePerformantInstrumentationparameters - the parameters to this step@Nullable public @Nullable InstrumentationContext<java.util.List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters, InstrumentationState rawState)
InstrumentationbeginValidation in interface InstrumentationbeginValidation in class SimplePerformantInstrumentationparameters - the parameters to this steprawState - the state created during the call to Instrumentation.createState(InstrumentationCreateStateParameters)InstrumentationContext object that will be called back when the step ends (assuming it's not null)@Nullable public @Nullable InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters instrumentationExecuteOperationParameters, InstrumentationState rawState)
InstrumentationbeginExecuteOperation in interface InstrumentationbeginExecuteOperation in class SimplePerformantInstrumentationinstrumentationExecuteOperationParameters - the parameters to this steprawState - the state created during the call to Instrumentation.createState(InstrumentationCreateStateParameters)InstrumentationContext object that will be called back when the step ends (assuming it's not null)protected AbortExecutionException mkAbortException(int totalComplexity, int maxComplexity)
totalComplexity - the complexity of the querymaxComplexity - the maximum complexity allowed