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)
BatchLoaderRegistry
When 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 BatchLoaderRegistry
K
- 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)
BatchLoaderRegistry
DataLoader
.
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 BatchLoaderRegistry
K
- 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 DataLoader
public void registerDataLoaders(org.dataloader.DataLoaderRegistry registry, GraphQLContext context)
DataLoaderRegistrar
DataLoaderRegistry
from the
the ExecutionInput
.registerDataLoaders
in interface DataLoaderRegistrar
registry
- 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
.