Class DataLoaderDispatcherInstrumentation
- java.lang.Object
-
- graphql.execution.instrumentation.SimplePerformantInstrumentation
-
- graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation
-
- All Implemented Interfaces:
Instrumentation
@PublicApi public class DataLoaderDispatcherInstrumentation extends SimplePerformantInstrumentation
This graphqlInstrumentationwill dispatch all the containedDataLoaders when each level of the graphql query is executed.This allows you to use
DataLoaders in yourDataFetchers to optimal loading of data.A DataLoaderDispatcherInstrumentation will be automatically added to the
GraphQLinstrumentation list if one is not present.- See Also:
DataLoader,DataLoaderRegistry
-
-
Field Summary
-
Fields inherited from class graphql.execution.instrumentation.SimplePerformantInstrumentation
INSTANCE
-
-
Constructor Summary
Constructors Constructor Description DataLoaderDispatcherInstrumentation()Creates a DataLoaderDispatcherInstrumentation with the default optionsDataLoaderDispatcherInstrumentation(DataLoaderDispatcherInstrumentationOptions options)Creates a DataLoaderDispatcherInstrumentation with the specified options
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable InstrumentationContext<ExecutionResult>beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState rawState)This is called just before the execution of the query operation is started.@Nullable ExecutionStrategyInstrumentationContextbeginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters, InstrumentationState rawState)This is called each time anExecutionStrategyis invoked, which may be multiple times per query as the engine recursively descends down over the query.@Nullable InstrumentationContext<java.lang.Object>beginFieldFetch(InstrumentationFieldFetchParameters parameters, InstrumentationState rawState)This is called just before a fieldDataFetcheris invoked.InstrumentationStatecreateState(InstrumentationCreateStateParameters parameters)This will be called just before execution to create an object 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 rawState)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 java.util.concurrent.CompletableFuture<ExecutionResult>instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters, InstrumentationState rawState)This is called to allow instrumentation to instrument the execution result in some way-
Methods inherited from class graphql.execution.instrumentation.SimplePerformantInstrumentation
beginExecuteOperation, beginExecution, beginExecution, beginExecutionStrategy, beginField, beginField, beginFieldComplete, beginFieldComplete, beginFieldFetch, beginFieldListComplete, beginFieldListComplete, beginParse, beginParse, beginSubscribedFieldEvent, beginSubscribedFieldEvent, beginValidation, beginValidation, createState, instrumentDataFetcher, instrumentDocumentAndVariables, instrumentDocumentAndVariables, instrumentExecutionContext, instrumentExecutionContext, instrumentExecutionInput, instrumentExecutionInput, instrumentExecutionResult, instrumentSchema, instrumentSchema
-
-
-
-
Constructor Detail
-
DataLoaderDispatcherInstrumentation
public DataLoaderDispatcherInstrumentation()
Creates a DataLoaderDispatcherInstrumentation with the default options
-
DataLoaderDispatcherInstrumentation
public DataLoaderDispatcherInstrumentation(DataLoaderDispatcherInstrumentationOptions options)
Creates a DataLoaderDispatcherInstrumentation with the specified options- Parameters:
options- the options to control the behaviour
-
-
Method Detail
-
createState
public InstrumentationState createState(InstrumentationCreateStateParameters parameters)
Description copied from interface:InstrumentationThis will be called just before execution to create an object that is given back to all instrumentation methods to allow them to have per execution request state- Specified by:
createStatein interfaceInstrumentation- Overrides:
createStatein classSimplePerformantInstrumentation- Parameters:
parameters- the parameters to this step- Returns:
- a state object that is passed to each method
-
instrumentDataFetcher
@NotNull public @NotNull DataFetcher<?> instrumentDataFetcher(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters, InstrumentationState rawState)
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- Overrides:
instrumentDataFetcherin classSimplePerformantInstrumentation- Parameters:
dataFetcher- the data fetcher about to be usedparameters- the parameters describing the field to be fetchedrawState- the state created during the call toInstrumentation.createState(InstrumentationCreateStateParameters)- Returns:
- a non null instrumented DataFetcher, the default is to return to the same object
-
beginExecuteOperation
@Nullable public @Nullable InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState rawState)
Description copied from interface:InstrumentationThis is called just before the execution of the query operation is started.- Specified by:
beginExecuteOperationin interfaceInstrumentation- Overrides:
beginExecuteOperationin classSimplePerformantInstrumentation- Parameters:
parameters- the parameters to this steprawState- the state created during the call toInstrumentation.createState(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 rawState)
Description copied from interface:InstrumentationThis is called each time anExecutionStrategyis invoked, which may be multiple times per query as the engine recursively descends down over the query.- Specified by:
beginExecutionStrategyin interfaceInstrumentation- Overrides:
beginExecutionStrategyin classSimplePerformantInstrumentation- Parameters:
parameters- the parameters to this steprawState- the state created during the call toInstrumentation.createState(InstrumentationCreateStateParameters)- Returns:
- a nullable
ExecutionStrategyInstrumentationContextobject 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 rawState)
Description copied from interface:InstrumentationThis is called just before a fieldDataFetcheris invoked.- Specified by:
beginFieldFetchin interfaceInstrumentation- Overrides:
beginFieldFetchin classSimplePerformantInstrumentation- Parameters:
parameters- the parameters to this steprawState- the state created during the call toInstrumentation.createState(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
instrumentExecutionResult
@NotNull public @NotNull java.util.concurrent.CompletableFuture<ExecutionResult> instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters, InstrumentationState rawState)
Description copied from interface:InstrumentationThis is called to allow instrumentation to instrument the execution result in some way- Specified by:
instrumentExecutionResultin interfaceInstrumentation- Overrides:
instrumentExecutionResultin classSimplePerformantInstrumentation- Parameters:
executionResult-CompletableFutureof the result to instrumentparameters- the parameters to this steprawState- the state created during the call toInstrumentation.createState(InstrumentationCreateStateParameters)- Returns:
- a new execution result completable future
-
-