@PublicApi public class MaxQueryDepthInstrumentation extends SimpleInstrumentation
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 |
---|---|
InstrumentationContext<java.util.List<ValidationError>> |
beginValidation(InstrumentationValidationParameters parameters)
This is called just before the parsed query document is validated.
|
protected AbortExecutionException |
mkAbortException(int depth,
int maxDepth)
Called to generate your own error message or custom exception class
|
beginExecuteOperation, beginExecution, beginExecutionStrategy, beginField, beginFieldFetch, beginParse
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
beginFieldComplete, beginFieldListComplete, beginSubscribedFieldEvent, createState, createState, instrumentDataFetcher, instrumentDocumentAndVariables, instrumentExecutionContext, instrumentExecutionInput, instrumentExecutionResult, 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 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 depth, int maxDepth)
depth
- the depth of the querymaxDepth
- the maximum depth allowed