Class SimplePerformantInstrumentation
- java.lang.Object
-
- graphql.execution.instrumentation.SimplePerformantInstrumentation
-
- All Implemented Interfaces:
Instrumentation
- Direct Known Subclasses:
ExecutorInstrumentation,FieldValidationInstrumentation,MaxQueryComplexityInstrumentation,MaxQueryDepthInstrumentation,TracingInstrumentation
@PublicApi public class SimplePerformantInstrumentation extends java.lang.Object implements Instrumentation
An implementation ofInstrumentationthat does nothing. It can be used as a base for derived classes where you only implement the methods you want to. The reason this class is designated as more performant is that it does not delegate back to the deprecated methods and allocate a new state object per call.This behavior was left in place for backwards compatibility reasons inside
InstrumentationandSimpleInstrumentationbut has not been done in this class since no existing classes could have derived from it. If you want more performant behavior on methods you don't implement then this is the base class to use, since it will not delegate back to old methods and cause a new state to be allocated.
-
-
Field Summary
Fields Modifier and Type Field Description static SimplePerformantInstrumentationINSTANCEA singleton instance of aInstrumentationthat does nothing
-
Constructor Summary
Constructors Constructor Description SimplePerformantInstrumentation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable ExecuteObjectInstrumentationContextbeginExecuteObject(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state)This is called each time anExecutionStrategyobject resolution is called, which may be multiple times per query as the engine recursively descends over the query.@Nullable InstrumentationContext<ExecutionResult>beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state)This is called just before the execution of the query operation is started.@Nullable InstrumentationContext<ExecutionResult>beginExecution(InstrumentationExecutionParameters parameters, InstrumentationState state)This is called right at the start of query execution, and it's the first step in the instrumentation chain.@Nullable ExecutionStrategyInstrumentationContextbeginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state)This is called each time anExecutionStrategyis invoked, which may be multiple times per query as the engine recursively descends over the query.@Nullable InstrumentationContext<java.lang.Object>beginFieldCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state)This is called just before the complete field is started.@Nullable InstrumentationContext<java.lang.Object>beginFieldExecution(InstrumentationFieldParameters parameters, InstrumentationState state)This is called just before a field is resolved into a value.@Nullable InstrumentationContext<java.lang.Object>beginFieldFetch(InstrumentationFieldFetchParameters parameters, InstrumentationState state)This is called just before a fieldDataFetcheris invoked.@Nullable InstrumentationContext<java.lang.Object>beginFieldListCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state)This is called just before the complete field list is started.@Nullable InstrumentationContext<Document>beginParse(InstrumentationExecutionParameters parameters, InstrumentationState state)This is called just before a query is parsed.@Nullable InstrumentationContext<ExecutionResult>beginSubscribedFieldEvent(InstrumentationFieldParameters parameters, InstrumentationState state)This is called each time a subscription field produces a new reactive stream event value and it needs to be mapped over via the graphql field subselection.@Nullable InstrumentationContext<java.util.List<ValidationError>>beginValidation(InstrumentationValidationParameters parameters, InstrumentationState state)This is called just before the parsed query document is validated.@Nullable InstrumentationStatecreateState(InstrumentationCreateStateParameters parameters)This method is retained for backwards compatibility reasons so that previousInstrumentationimplementations continue to work.@Nullable java.util.concurrent.CompletableFuture<InstrumentationState>createStateAsync(InstrumentationCreateStateParameters parameters)This will be called just before execution to create an object, in an asynchronous manner, that is given back to all instrumentation methods to allow them to have per execution request state@NotNull DataFetcher<?>instrumentDataFetcher(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters, InstrumentationState state)This is called to instrument aDataFetcherjust before it is used to fetch a field, allowing you to adjust what information is passed back or record information about specific data fetches.@NotNull DocumentAndVariablesinstrumentDocumentAndVariables(DocumentAndVariables documentAndVariables, InstrumentationExecutionParameters parameters, InstrumentationState state)This is called to instrument aDocumentand variables before it is used allowing you to adjust the query AST if you so desire@NotNull ExecutionContextinstrumentExecutionContext(ExecutionContext executionContext, InstrumentationExecutionParameters parameters, InstrumentationState state)This is called to instrument aExecutionContextbefore it is used to execute a query, allowing you to adjust the base data used.@NotNull ExecutionInputinstrumentExecutionInput(ExecutionInput executionInput, InstrumentationExecutionParameters parameters, InstrumentationState state)This is called to instrument aExecutionInputbefore it is used to parse, validate and execute a query, allowing you to adjust what query input parameters are used@NotNull java.util.concurrent.CompletableFuture<ExecutionResult>instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters, InstrumentationState state)This is called to allow instrumentation to instrument the execution result in some way@NotNull GraphQLSchemainstrumentSchema(GraphQLSchema schema, InstrumentationExecutionParameters parameters, InstrumentationState state)This is called to instrument aGraphQLSchemabefore it is used to parse, validate and execute a query, allowing you to adjust what types are used.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface graphql.execution.instrumentation.Instrumentation
beginDeferredField
-
-
-
-
Field Detail
-
INSTANCE
public static final SimplePerformantInstrumentation INSTANCE
A singleton instance of aInstrumentationthat does nothing
-
-
Method Detail
-
createStateAsync
@Nullable public @Nullable java.util.concurrent.CompletableFuture<InstrumentationState> createStateAsync(InstrumentationCreateStateParameters parameters)
Description copied from interface:InstrumentationThis will be called just before execution to create an object, in an asynchronous manner, that is given back to all instrumentation methods to allow them to have per execution request state- Specified by:
createStateAsyncin interfaceInstrumentation- Parameters:
parameters- the parameters to this step- Returns:
- a state object that is passed to each method
-
createState
@Nullable public @Nullable InstrumentationState createState(InstrumentationCreateStateParameters parameters)
Description copied from interface:InstrumentationThis method is retained for backwards compatibility reasons so that previousInstrumentationimplementations continue to work. The graphql-java code only calledInstrumentation.createStateAsync(InstrumentationCreateStateParameters)but the default implementation calls back to this method.- Specified by:
createStatein interfaceInstrumentation- Parameters:
parameters- the parameters to this step- Returns:
- a state object that is passed to each method
-
beginExecution
@Nullable public @Nullable InstrumentationContext<ExecutionResult> beginExecution(InstrumentationExecutionParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called right at the start of query execution, and it's the first step in the instrumentation chain.- Specified by:
beginExecutionin interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginParse
@Nullable public @Nullable InstrumentationContext<Document> beginParse(InstrumentationExecutionParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called just before a query is parsed.- Specified by:
beginParsein interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginValidation
@Nullable public @Nullable InstrumentationContext<java.util.List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called just before the parsed query document is validated.- Specified by:
beginValidationin interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginExecuteOperation
@Nullable public @Nullable InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called just before the execution of the query operation is started.- Specified by:
beginExecuteOperationin interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginExecutionStrategy
@Nullable public @Nullable ExecutionStrategyInstrumentationContext beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called each time anExecutionStrategyis invoked, which may be multiple times per query as the engine recursively descends over the query.- Specified by:
beginExecutionStrategyin interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
ExecutionStrategyInstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginExecuteObject
@Nullable public @Nullable ExecuteObjectInstrumentationContext beginExecuteObject(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called each time anExecutionStrategyobject resolution is called, which may be multiple times per query as the engine recursively descends over the query.- Specified by:
beginExecuteObjectin interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
ExecutionStrategyInstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginSubscribedFieldEvent
@Nullable public @Nullable InstrumentationContext<ExecutionResult> beginSubscribedFieldEvent(InstrumentationFieldParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called each time a subscription field produces a new reactive stream event value and it needs to be mapped over via the graphql field subselection.- Specified by:
beginSubscribedFieldEventin interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginFieldExecution
@Nullable public @Nullable InstrumentationContext<java.lang.Object> beginFieldExecution(InstrumentationFieldParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called just before a field is resolved into a value.- Specified by:
beginFieldExecutionin interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginFieldFetch
@Nullable public @Nullable InstrumentationContext<java.lang.Object> beginFieldFetch(InstrumentationFieldFetchParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called just before a fieldDataFetcheris invoked.- Specified by:
beginFieldFetchin interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginFieldCompletion
@Nullable public @Nullable InstrumentationContext<java.lang.Object> beginFieldCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called just before the complete field is started.- Specified by:
beginFieldCompletionin interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginFieldListCompletion
@Nullable public @Nullable InstrumentationContext<java.lang.Object> beginFieldListCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called just before the complete field list is started.- Specified by:
beginFieldListCompletionin interfaceInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
instrumentExecutionInput
@NotNull public @NotNull ExecutionInput instrumentExecutionInput(ExecutionInput executionInput, InstrumentationExecutionParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called to instrument aExecutionInputbefore it is used to parse, validate and execute a query, allowing you to adjust what query input parameters are used- Specified by:
instrumentExecutionInputin interfaceInstrumentation- Parameters:
executionInput- the execution input to be usedparameters- the parameters describing the field to be fetchedstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a non-null instrumented ExecutionInput, the default is to return to the same object
-
instrumentDocumentAndVariables
@NotNull public @NotNull DocumentAndVariables instrumentDocumentAndVariables(DocumentAndVariables documentAndVariables, InstrumentationExecutionParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called to instrument aDocumentand variables before it is used allowing you to adjust the query AST if you so desire- Specified by:
instrumentDocumentAndVariablesin interfaceInstrumentation- Parameters:
documentAndVariables- the document and variables to be usedparameters- the parameters describing the executionstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a non-null instrumented DocumentAndVariables, the default is to return to the same objects
-
instrumentSchema
@NotNull public @NotNull GraphQLSchema instrumentSchema(GraphQLSchema schema, InstrumentationExecutionParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called to instrument aGraphQLSchemabefore it is used to parse, validate and execute a query, allowing you to adjust what types are used.- Specified by:
instrumentSchemain interfaceInstrumentation- Parameters:
schema- the schema to be usedparameters- the parameters describing the field to be fetchedstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a non-null instrumented GraphQLSchema, the default is to return to the same object
-
instrumentExecutionContext
@NotNull public @NotNull ExecutionContext instrumentExecutionContext(ExecutionContext executionContext, InstrumentationExecutionParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called to instrument aExecutionContextbefore it is used to execute a query, allowing you to adjust the base data used.- Specified by:
instrumentExecutionContextin interfaceInstrumentation- Parameters:
executionContext- the execution context to be usedparameters- the parameters describing the field to be fetchedstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a non-null instrumented ExecutionContext, the default is to return to the same object
-
instrumentDataFetcher
@NotNull public @NotNull DataFetcher<?> instrumentDataFetcher(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called to instrument aDataFetcherjust before it is used to fetch a field, allowing you to adjust what information is passed back or record information about specific data fetches. Note the same data fetcher instance maybe presented to you many times and that data fetcher implementations widely vary.- Specified by:
instrumentDataFetcherin interfaceInstrumentation- Parameters:
dataFetcher- the data fetcher about to be usedparameters- the parameters describing the field to be fetchedstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a non-null instrumented DataFetcher, the default is to return to the same object
-
instrumentExecutionResult
@NotNull public @NotNull java.util.concurrent.CompletableFuture<ExecutionResult> instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters, InstrumentationState state)
Description copied from interface:InstrumentationThis is called to allow instrumentation to instrument the execution result in some way- Specified by:
instrumentExecutionResultin interfaceInstrumentation- Parameters:
executionResult-CompletableFutureof the result to instrumentparameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a new execution result completable future
-
-