public class DefaultBatchLoaderRegistry extends Object implements BatchLoaderRegistry
BatchLoaderRegistry that accepts
registrations, and also an implementation of DataLoaderRegistrar to
apply those registrations to a DataLoaderRegistry.BatchLoaderRegistry.RegistrationSpec<K,V>| Constructor and Description |
|---|
DefaultBatchLoaderRegistry() |
| Modifier and Type | Method and Description |
|---|---|
<K,V> BatchLoaderRegistry.RegistrationSpec<K,V> |
forName(String name)
Begin the registration of a new batch load function by specifying the
name for the
DataLoader. |
<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.
|
void |
registerDataLoaders(org.dataloader.DataLoaderRegistry registry,
GraphQLContext context)
Callback that provides access to the
DataLoaderRegistry from the
the ExecutionInput. |
public <K,V> BatchLoaderRegistry.RegistrationSpec<K,V> forTypePair(Class<K> keyType, Class<V> valueType)
BatchLoaderRegistryWhen this method is used, the name for the
DataLoader is automatically set as defined in
BatchLoaderRegistry.RegistrationSpec.withName(String), and likewise,
@SchemaMapping handler methods can transparenly locate and
inject a DataLoader<T> argument based on the generic type
<T>.
forTypePair in interface BatchLoaderRegistryK - the key typeV - the value typekeyType - the type of keys that will be used as inputvalueType - the type of value that will be returned as outputpublic <K,V> BatchLoaderRegistry.RegistrationSpec<K,V> forName(String name)
BatchLoaderRegistryDataLoader.
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.
forName in interface BatchLoaderRegistryK - the type of keys that will be used as inputV - the type of values that will be used as outputname - the name to use to register a DataLoaderpublic void registerDataLoaders(org.dataloader.DataLoaderRegistry registry,
GraphQLContext context)
DataLoaderRegistrarDataLoaderRegistry from the
the ExecutionInput.registerDataLoaders in interface DataLoaderRegistrarregistry - the registry to make registrations againstcontext - the GraphQLContext from the ExecutionInput that registrars
should set in the DataLoaderOptions so that batch
loaders can access it via BatchLoaderEnvironment.