K
- the type of the key that identifies the valueV
- the type of the data valuepublic static interface BatchLoaderRegistry.RegistrationSpec<K,V>
Modifier and Type | Method and Description |
---|---|
void |
registerBatchLoader(BiFunction<List<K>,org.dataloader.BatchLoaderEnvironment,reactor.core.publisher.Flux<V>> loader)
Register the give batch loading function.
|
void |
registerMappedBatchLoader(BiFunction<Set<K>,org.dataloader.BatchLoaderEnvironment,reactor.core.publisher.Mono<Map<K,V>>> loader)
A variant of
registerBatchLoader(BiFunction) that returns a
Map of key-value pairs, which is useful is there aren't values for all keys. |
BatchLoaderRegistry.RegistrationSpec<K,V> |
withName(String name)
Customize the name under which the
DataLoader
is registered and can be accessed in the data layer. |
BatchLoaderRegistry.RegistrationSpec<K,V> |
withOptions(Consumer<org.dataloader.DataLoaderOptions> optionsConsumer)
Customize the
DataLoaderOptions to use to create the
DataLoader via DataLoaderFactory . |
BatchLoaderRegistry.RegistrationSpec<K,V> |
withOptions(org.dataloader.DataLoaderOptions options)
Set the
DataLoaderOptions to use to create the
DataLoader via DataLoaderFactory . |
BatchLoaderRegistry.RegistrationSpec<K,V> withName(String name)
DataLoader
is registered and can be accessed in the data layer.
By default, this is the full class name of the value type, if the
value type is specified via BatchLoaderRegistry.forTypePair(Class, Class)
.
name
- the name to useBatchLoaderRegistry.RegistrationSpec<K,V> withOptions(Consumer<org.dataloader.DataLoaderOptions> optionsConsumer)
DataLoaderOptions
to use to create the
DataLoader
via DataLoaderFactory
.
Note: Do not set
DataLoaderOptions.setBatchLoaderContextProvider(BatchLoaderContextProvider)
as this will be set later to a provider that returns the context from
ExecutionInput.getGraphQLContext()
, so that batch loading
functions and data fetchers can rely on access to the same context.
optionsConsumer
- callback to customize the options, invoked
immediately and given access to the options instanceBatchLoaderRegistry.RegistrationSpec<K,V> withOptions(org.dataloader.DataLoaderOptions options)
DataLoaderOptions
to use to create the
DataLoader
via DataLoaderFactory
.
Note: Do not set
DataLoaderOptions.setBatchLoaderContextProvider(BatchLoaderContextProvider)
as this will be set later to a provider that returns the context from
ExecutionInput.getGraphQLContext()
, so that batch loading
functions and data fetchers can rely on access to the same context.
options
- the options to usevoid registerBatchLoader(BiFunction<List<K>,org.dataloader.BatchLoaderEnvironment,reactor.core.publisher.Flux<V>> loader)
The values returned from the function must match the order and
the number of keys, with null
for missing values.
Please, see BatchLoader
.
loader
- the loader functionBatchLoader
void registerMappedBatchLoader(BiFunction<Set<K>,org.dataloader.BatchLoaderEnvironment,reactor.core.publisher.Mono<Map<K,V>>> loader)
registerBatchLoader(BiFunction)
that returns a
Map of key-value pairs, which is useful is there aren't values for all keys.
Please see MappedBatchLoader
.loader
- the loader functionMappedBatchLoader