Class ChainedInstrumentation
java.lang.Object
graphql.execution.instrumentation.ChainedInstrumentation
- All Implemented Interfaces:
Instrumentation
- Direct Known Subclasses:
NoContextChainedInstrumentation
This allows you to chain together a number of
Instrumentation implementations
and run them in sequence. The list order of instrumentation objects is always guaranteed to be followed and
the InstrumentationState objects they create will be passed back to the originating
implementation.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.google.common.collect.ImmutableList<Instrumentation> -
Constructor Summary
ConstructorsConstructorDescriptionChainedInstrumentation(Instrumentation... instrumentations) ChainedInstrumentation(List<Instrumentation> instrumentations) -
Method Summary
Modifier and TypeMethodDescriptionbeginDeferredField(InstrumentationFieldParameters parameters, InstrumentationState state) This is called just before a deferred field is resolved into a value.@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.beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state) This is called just before the execution of the query operation is started.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.beginExecutionStrategy(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<Object> beginFieldCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state) This is called just before the complete field is started.@Nullable InstrumentationContext<Object> beginFieldExecution(InstrumentationFieldParameters parameters, InstrumentationState state) This is called just before a field is resolved into a value.beginFieldFetch(InstrumentationFieldFetchParameters parameters, InstrumentationState state) This is called just before a fieldDataFetcheris invoked.beginFieldFetching(InstrumentationFieldFetchParameters parameters, InstrumentationState state) This is called just before a fieldDataFetcheris invoked.@Nullable InstrumentationContext<Object> beginFieldListCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state) This is called just before the complete field list is started.beginParse(InstrumentationExecutionParameters parameters, InstrumentationState state) This is called just before a query is parsed.@Nullable InstrumentationContext<Void> beginReactiveResults(InstrumentationReactiveResultsParameters parameters, InstrumentationState state) This is called just before the execution of any reactive results, namely incremental deferred results or subscriptions.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.beginValidation(InstrumentationValidationParameters parameters, InstrumentationState state) This is called just before the parsed query document is validated.protected voidchainedConsume(InstrumentationState state, BiConsumer<Instrumentation, InstrumentationState> stateConsumer) protected <T> com.google.common.collect.ImmutableList<T> chainedMapAndDropNulls(InstrumentationState state, BiFunction<Instrumentation, InstrumentationState, T> mapper) @NonNull 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@NonNull 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.@NonNull 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@NonNull 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.@NonNull 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@NonNull CompletableFuture<ExecutionResult> instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters, InstrumentationState state) This is called to allow instrumentation to instrument the execution result in some way@NonNull 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, waitMethods inherited from interface graphql.execution.instrumentation.Instrumentation
createState
-
Field Details
-
instrumentations
-
-
Constructor Details
-
ChainedInstrumentation
-
ChainedInstrumentation
-
-
Method Details
-
getInstrumentations
- Returns:
- the list of instrumentations in play
-
chainedMapAndDropNulls
protected <T> com.google.common.collect.ImmutableList<T> chainedMapAndDropNulls(InstrumentationState state, BiFunction<Instrumentation, InstrumentationState, T> mapper) -
chainedConsume
protected void chainedConsume(InstrumentationState state, BiConsumer<Instrumentation, InstrumentationState> stateConsumer) -
createStateAsync
public @NonNull 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
-
beginExecution
public 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
public 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
public InstrumentationContext<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
public 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)
-
beginReactiveResults
public @Nullable InstrumentationContext<Void> beginReactiveResults(InstrumentationReactiveResultsParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before the execution of any reactive results, namely incremental deferred results or subscriptions. When thePublisherfinally ends (with either aThrowableor none) then theInstrumentationContextwil be called back to say the reactive results have finished.- Specified by:
beginReactiveResultsin 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
public 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
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)
-
beginDeferredField
@ExperimentalApi public InstrumentationContext<Object> beginDeferredField(InstrumentationFieldParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis 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:
beginDeferredFieldin 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)
-
beginSubscribedFieldEvent
public 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
public @Nullable InstrumentationContext<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
public InstrumentationContext<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)
-
beginFieldFetching
public FieldFetchingInstrumentationContext beginFieldFetching(InstrumentationFieldFetchParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before a fieldDataFetcheris invoked. TheFieldFetchingInstrumentationContext.onFetchedValue(Object)callback will be invoked once a value is returned by aDataFetcherbut perhaps before its value is completed if it's aCompletableFuturevalue.This method is the replacement method for the now deprecated
Instrumentation.beginFieldFetch(InstrumentationFieldFetchParameters, InstrumentationState)method, and it should be implemented in newInstrumentationclasses. This default version of this method calls back to the deprecatedInstrumentation.beginFieldFetch(InstrumentationFieldFetchParameters, InstrumentationState)method so that older implementations continue to work.- Specified by:
beginFieldFetchingin 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
public @Nullable InstrumentationContext<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
public @Nullable InstrumentationContext<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
public @NonNull 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
public @NonNull 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
public @NonNull 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
public @NonNull 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
public @NonNull 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
public @NonNull 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
-