Interface BatchLoaderRegistry
- All Superinterfaces:
DataLoaderRegistrar
- All Known Implementing Classes:
DefaultBatchLoaderRegistry
Registry for functions to batch load data values, given a set of keys.
At request time, each function is registered as a
DataLoader
in the DataLoaderRegistry
and can be accessed in the data layer to load related entities while avoiding
the N+1 select problem.
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev
- See Also:
-
- Using DataLoader
BatchLoader
MappedBatchLoader
DataLoader
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Spec to complete the registration of a batch loading function. -
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.Methods inherited from interface org.springframework.graphql.execution.DataLoaderRegistrar
hasRegistrations, registerDataLoaders
-
Method Details
-
forTypePair
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.When this method is used, the name for the
DataLoader
is automatically set as defined inBatchLoaderRegistry.RegistrationSpec.withName(String)
, and likewise,@SchemaMapping
handler methods can transparenly locate and inject aDataLoader<T>
argument based on the generic type<T>
.- 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
Begin 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@SchemaMapping
handler method needs to match the name given here.- 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
-