Class ChainedInstrumentation
- java.lang.Object
-
- graphql.execution.instrumentation.ChainedInstrumentation
-
- All Implemented Interfaces:
Instrumentation
- Direct Known Subclasses:
NoContextChainedInstrumentation
@PublicApi public class ChainedInstrumentation extends java.lang.Object implements Instrumentation
This allows you to chain together a number ofInstrumentation
implementations and run them in sequence. The list order of instrumentation objects is always guaranteed to be followed and theInstrumentationState
objects they create will be passed back to the originating implementation.- See Also:
Instrumentation
-
-
Field Summary
Fields Modifier and Type Field Description protected com.google.common.collect.ImmutableList<Instrumentation>
instrumentations
-
Constructor Summary
Constructors Constructor Description ChainedInstrumentation(Instrumentation... instrumentations)
ChainedInstrumentation(java.util.List<Instrumentation> instrumentations)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InstrumentationContext<java.lang.Object>
beginDeferredField(InstrumentationState instrumentationState)
This is called just before a deferred field is resolved into a value.@Nullable ExecuteObjectInstrumentationContext
beginExecuteObject(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state)
This is called each time anExecutionStrategy
object resolution is called, which may be multiple times per query as the engine recursively descends over the query.InstrumentationContext<ExecutionResult>
beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state)
This is called just before the execution of the query operation is started.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.ExecutionStrategyInstrumentationContext
beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state)
This is called each time anExecutionStrategy
is 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.InstrumentationContext<java.lang.Object>
beginFieldFetch(InstrumentationFieldFetchParameters parameters, InstrumentationState state)
This is called just before a fieldDataFetcher
is invoked.FieldFetchingInstrumentationContext
beginFieldFetching(InstrumentationFieldFetchParameters parameters, InstrumentationState state)
This is called just before a fieldDataFetcher
is invoked.@Nullable InstrumentationContext<java.lang.Object>
beginFieldListCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state)
This is called just before the complete field list is started.InstrumentationContext<Document>
beginParse(InstrumentationExecutionParameters parameters, InstrumentationState state)
This is called just before a query is parsed.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.InstrumentationContext<java.util.List<ValidationError>>
beginValidation(InstrumentationValidationParameters parameters, InstrumentationState state)
This is called just before the parsed query document is validated.protected void
chainedConsume(InstrumentationState state, java.util.function.BiConsumer<Instrumentation,InstrumentationState> stateConsumer)
protected <T> com.google.common.collect.ImmutableList<T>
chainedMapAndDropNulls(InstrumentationState state, java.util.function.BiFunction<Instrumentation,InstrumentationState,T> mapper)
@NotNull 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 statejava.util.List<Instrumentation>
getInstrumentations()
@NotNull DataFetcher<?>
instrumentDataFetcher(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters, InstrumentationState state)
This is called to instrument aDataFetcher
just 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 DocumentAndVariables
instrumentDocumentAndVariables(DocumentAndVariables documentAndVariables, InstrumentationExecutionParameters parameters, InstrumentationState state)
This is called to instrument aDocument
and variables before it is used allowing you to adjust the query AST if you so desire@NotNull ExecutionContext
instrumentExecutionContext(ExecutionContext executionContext, InstrumentationExecutionParameters parameters, InstrumentationState state)
This is called to instrument aExecutionContext
before it is used to execute a query, allowing you to adjust the base data used.@NotNull ExecutionInput
instrumentExecutionInput(ExecutionInput executionInput, InstrumentationExecutionParameters parameters, InstrumentationState state)
This is called to instrument aExecutionInput
before 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 GraphQLSchema
instrumentSchema(GraphQLSchema schema, InstrumentationExecutionParameters parameters, InstrumentationState state)
This is called to instrument aGraphQLSchema
before 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
createState
-
-
-
-
Field Detail
-
instrumentations
protected final com.google.common.collect.ImmutableList<Instrumentation> instrumentations
-
-
Constructor Detail
-
ChainedInstrumentation
public ChainedInstrumentation(java.util.List<Instrumentation> instrumentations)
-
ChainedInstrumentation
public ChainedInstrumentation(Instrumentation... instrumentations)
-
-
Method Detail
-
getInstrumentations
public java.util.List<Instrumentation> getInstrumentations()
- Returns:
- the list of instrumentations in play
-
chainedMapAndDropNulls
protected <T> com.google.common.collect.ImmutableList<T> chainedMapAndDropNulls(InstrumentationState state, java.util.function.BiFunction<Instrumentation,InstrumentationState,T> mapper)
-
chainedConsume
protected void chainedConsume(InstrumentationState state, java.util.function.BiConsumer<Instrumentation,InstrumentationState> stateConsumer)
-
createStateAsync
@NotNull public @NotNull java.util.concurrent.CompletableFuture<InstrumentationState> createStateAsync(InstrumentationCreateStateParameters parameters)
Description copied from interface:Instrumentation
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- Specified by:
createStateAsync
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this step- Returns:
- a state object that is passed to each method
-
beginExecution
public InstrumentationContext<ExecutionResult> beginExecution(InstrumentationExecutionParameters parameters, InstrumentationState state)
Description copied from interface:Instrumentation
This is called right at the start of query execution, and it's the first step in the instrumentation chain.- Specified by:
beginExecution
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)
-
beginParse
public InstrumentationContext<Document> beginParse(InstrumentationExecutionParameters parameters, InstrumentationState state)
Description copied from interface:Instrumentation
This is called just before a query is parsed.- Specified by:
beginParse
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)
-
beginValidation
public InstrumentationContext<java.util.List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters, InstrumentationState state)
Description copied from interface:Instrumentation
This is called just before the parsed query document is validated.- Specified by:
beginValidation
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)
-
beginExecuteOperation
public InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state)
Description copied from interface:Instrumentation
This is called just before the execution of the query operation is started.- Specified by:
beginExecuteOperation
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)
-
beginExecutionStrategy
public ExecutionStrategyInstrumentationContext beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state)
Description copied from interface:Instrumentation
This is called each time anExecutionStrategy
is invoked, which may be multiple times per query as the engine recursively descends over the query.- Specified by:
beginExecutionStrategy
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
ExecutionStrategyInstrumentationContext
object 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:Instrumentation
This is called each time anExecutionStrategy
object resolution is called, which may be multiple times per query as the engine recursively descends over the query.- Specified by:
beginExecuteObject
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
ExecutionStrategyInstrumentationContext
object that will be called back when the step ends (assuming it's not null)
-
beginDeferredField
@ExperimentalApi public InstrumentationContext<java.lang.Object> beginDeferredField(InstrumentationState instrumentationState)
Description copied from interface:Instrumentation
This is called just before a deferred field is resolved into a value.This is an EXPERIMENTAL instrumentation callback. The method signature will definitely change.
- Specified by:
beginDeferredField
in interfaceInstrumentation
- Parameters:
instrumentationState
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
ExecutionStrategyInstrumentationContext
object that will be called back when the step ends (assuming it's not null)
-
beginSubscribedFieldEvent
public InstrumentationContext<ExecutionResult> beginSubscribedFieldEvent(InstrumentationFieldParameters parameters, InstrumentationState state)
Description copied from interface:Instrumentation
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.- Specified by:
beginSubscribedFieldEvent
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object 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:Instrumentation
This is called just before a field is resolved into a value.- Specified by:
beginFieldExecution
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)
-
beginFieldFetch
public InstrumentationContext<java.lang.Object> beginFieldFetch(InstrumentationFieldFetchParameters parameters, InstrumentationState state)
Description copied from interface:Instrumentation
This is called just before a fieldDataFetcher
is invoked.- Specified by:
beginFieldFetch
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)
-
beginFieldFetching
public FieldFetchingInstrumentationContext beginFieldFetching(InstrumentationFieldFetchParameters parameters, InstrumentationState state)
Description copied from interface:Instrumentation
This is called just before a fieldDataFetcher
is invoked. TheFieldFetchingInstrumentationContext.onFetchedValue(Object)
callback will be invoked once a value is returned by aDataFetcher
but perhaps before its value is completed if it's aCompletableFuture
value.This method is the replacement method for the now deprecated
Instrumentation.beginFieldFetch(InstrumentationFieldFetchParameters, InstrumentationState)
method, and it should be implemented in newInstrumentation
classes. This default version of this method calls back to the deprecatedInstrumentation.beginFieldFetch(InstrumentationFieldFetchParameters, InstrumentationState)
method so that older implementations continue to work.- Specified by:
beginFieldFetching
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object 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:Instrumentation
This is called just before the complete field is started.- Specified by:
beginFieldCompletion
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object 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:Instrumentation
This is called just before the complete field list is started.- Specified by:
beginFieldListCompletion
in interfaceInstrumentation
- Parameters:
parameters
- the parameters to this stepstate
- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object 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:Instrumentation
This is called to instrument aExecutionInput
before it is used to parse, validate and execute a query, allowing you to adjust what query input parameters are used- Specified by:
instrumentExecutionInput
in 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:Instrumentation
This is called to instrument aDocument
and variables before it is used allowing you to adjust the query AST if you so desire- Specified by:
instrumentDocumentAndVariables
in 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:Instrumentation
This is called to instrument aGraphQLSchema
before it is used to parse, validate and execute a query, allowing you to adjust what types are used.- Specified by:
instrumentSchema
in 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:Instrumentation
This is called to instrument aExecutionContext
before it is used to execute a query, allowing you to adjust the base data used.- Specified by:
instrumentExecutionContext
in 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:Instrumentation
This is called to instrument aDataFetcher
just 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:
instrumentDataFetcher
in 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:Instrumentation
This is called to allow instrumentation to instrument the execution result in some way- Specified by:
instrumentExecutionResult
in interfaceInstrumentation
- Parameters:
executionResult
-CompletableFuture
of 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
-
-