Class DefaultBatchLoaderRegistry
java.lang.Object
org.springframework.graphql.execution.DefaultBatchLoaderRegistry
- All Implemented Interfaces:
BatchLoaderRegistry,DataLoaderRegistrar
Default implementation of
BatchLoaderRegistry that stores batch loader
registrations. Also, an implementation of DataLoaderRegistrar that
registers the batch loaders as DataLoaders in DataLoaderRegistry.- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.graphql.execution.BatchLoaderRegistry
BatchLoaderRegistry.RegistrationSpec<K,V> -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.DefaultBatchLoaderRegistry(Supplier<org.dataloader.DataLoaderOptions> defaultOptionsSupplier) Constructor with a defaultDataLoaderOptionssupplier to use as a starting point for batch loader registrations. -
Method Summary
Modifier and TypeMethodDescription<K,V> BatchLoaderRegistry.RegistrationSpec<K, V> Begin the registration of a new batch load function by specifying the name for theDataLoader.<K,V> BatchLoaderRegistry.RegistrationSpec<K, V> forTypePair(Class<K> keyType, Class<V> valueType) Begin the registration of a new batch load function by specifying the types of the keys and values that will be used as input and output.voidregisterDataLoaders(org.dataloader.DataLoaderRegistry registry, GraphQLContext context) Callback that provides access to theDataLoaderRegistryfrom the theExecutionInput.
-
Constructor Details
-
DefaultBatchLoaderRegistry
public DefaultBatchLoaderRegistry()Default constructor. -
DefaultBatchLoaderRegistry
public DefaultBatchLoaderRegistry(Supplier<org.dataloader.DataLoaderOptions> defaultOptionsSupplier) Constructor with a defaultDataLoaderOptionssupplier to use as a starting point for batch loader registrations.- Parameters:
defaultOptionsSupplier- a supplier for default dataloader options- Since:
- 1.1.0
-
-
Method Details
-
forTypePair
public <K,V> BatchLoaderRegistry.RegistrationSpec<K,V> forTypePair(Class<K> keyType, Class<V> valueType) Description copied from interface:BatchLoaderRegistryBegin the registration of a new batch load function by specifying the types of the keys and values that will be used as input and output.When this method is used, the name for the
DataLoaderis automatically set as defined inBatchLoaderRegistry.RegistrationSpec.withName(String), and likewise,@SchemaMappinghandler methods can transparenly locate and inject aDataLoader<T>argument based on the generic type<T>.- Specified by:
forTypePairin interfaceBatchLoaderRegistry- Type Parameters:
K- the key typeV- the value type- Parameters:
keyType- the type of keys that will be used as inputvalueType- the type of value that will be returned as output- Returns:
- a spec to complete the registration
-
forName
Description copied from interface:BatchLoaderRegistryBegin the registration of a new batch load function by specifying the name for theDataLoader.Note: when this method is used, the parameter name of a
DataLoader<T>argument in a@SchemaMappinghandler method needs to match the name given here.- Specified by:
forNamein interfaceBatchLoaderRegistry- Type Parameters:
K- the type of keys that will be used as inputV- the type of values that will be used as output- Parameters:
name- the name to use to register aDataLoader- Returns:
- a spec to complete the registration
-
registerDataLoaders
Description copied from interface:DataLoaderRegistrarCallback that provides access to theDataLoaderRegistryfrom the theExecutionInput.- Specified by:
registerDataLoadersin interfaceDataLoaderRegistrar- Parameters:
registry- the registry to make registrations againstcontext- the GraphQLContext from the ExecutionInput that registrars should set in theDataLoaderOptionsso that batch loaders can access it viaBatchLoaderEnvironment.
-