@PublicApi public class MaxQueryDepthInstrumentation extends SimplePerformantInstrumentation
Use the Function<QueryDepthInfo, Boolean>
parameter to supply a function to perform a custom action when the max depth is
exceeded. If the function returns true
a AbortExecutionException
is thrown.
INSTANCE
Constructor and Description |
---|
MaxQueryDepthInstrumentation(int maxDepth)
Creates a new instrumentation that tracks the query depth.
|
MaxQueryDepthInstrumentation(int maxDepth,
java.util.function.Function<QueryDepthInfo,java.lang.Boolean> maxQueryDepthExceededFunction)
Creates a new instrumentation that tracks the query depth.
|
Modifier and Type | Method and Description |
---|---|
@Nullable InstrumentationContext<ExecutionResult> |
beginExecuteOperation(InstrumentationExecuteOperationParameters parameters,
InstrumentationState state)
This is called just before the execution of the query operation is started.
|
protected AbortExecutionException |
mkAbortException(int depth,
int maxDepth)
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, beginValidation, createState, createState, instrumentDataFetcher, instrumentDataFetcher, instrumentDocumentAndVariables, instrumentDocumentAndVariables, instrumentExecutionContext, instrumentExecutionContext, instrumentExecutionInput, instrumentExecutionInput, instrumentExecutionResult, instrumentExecutionResult, instrumentSchema, instrumentSchema
public MaxQueryDepthInstrumentation(int maxDepth)
maxDepth
- max allowed depth, otherwise execution will be abortedpublic MaxQueryDepthInstrumentation(int maxDepth, java.util.function.Function<QueryDepthInfo,java.lang.Boolean> maxQueryDepthExceededFunction)
maxDepth
- max allowed depth, otherwise execution will be abortedmaxQueryDepthExceededFunction
- the function to perform when the max depth is exceeded@Nullable public @Nullable InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state)
Instrumentation
beginExecuteOperation
in interface Instrumentation
beginExecuteOperation
in class SimplePerformantInstrumentation
parameters
- the parameters to this stepstate
- 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 depth, int maxDepth)
depth
- the depth of the querymaxDepth
- the maximum depth allowed