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 graphqlInstrumentation
will dispatch all the containedDataLoader
s when each level of the graphql query is executed.This allows you to use
DataLoader
s in yourDataFetcher
s to optimal loading of data.A DataLoaderDispatcherInstrumentation will be automatically added to the
GraphQL
instrumentation 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 ExecutionStrategyInstrumentationContext
beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters, InstrumentationState rawState)
This is called each time anExecutionStrategy
is 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 fieldDataFetcher
is invoked.InstrumentationState
createState(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 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 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:Instrumentation
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- Specified by:
createState
in interfaceInstrumentation
- Overrides:
createState
in 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: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
- Overrides:
instrumentDataFetcher
in 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:Instrumentation
This is called just before the execution of the query operation is started.- Specified by:
beginExecuteOperation
in interfaceInstrumentation
- Overrides:
beginExecuteOperation
in classSimplePerformantInstrumentation
- Parameters:
parameters
- the parameters to this steprawState
- the state created during the call toInstrumentation.createState(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object 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:Instrumentation
This is called each time anExecutionStrategy
is invoked, which may be multiple times per query as the engine recursively descends down over the query.- Specified by:
beginExecutionStrategy
in interfaceInstrumentation
- Overrides:
beginExecutionStrategy
in classSimplePerformantInstrumentation
- Parameters:
parameters
- the parameters to this steprawState
- the state created during the call toInstrumentation.createState(InstrumentationCreateStateParameters)
- Returns:
- a nullable
ExecutionStrategyInstrumentationContext
object 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:Instrumentation
This is called just before a fieldDataFetcher
is invoked.- Specified by:
beginFieldFetch
in interfaceInstrumentation
- Overrides:
beginFieldFetch
in classSimplePerformantInstrumentation
- Parameters:
parameters
- the parameters to this steprawState
- the state created during the call toInstrumentation.createState(InstrumentationCreateStateParameters)
- Returns:
- a nullable
InstrumentationContext
object 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:Instrumentation
This is called to allow instrumentation to instrument the execution result in some way- Specified by:
instrumentExecutionResult
in interfaceInstrumentation
- Overrides:
instrumentExecutionResult
in classSimplePerformantInstrumentation
- Parameters:
executionResult
-CompletableFuture
of 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
-
-