Interface BatchLoaderRegistry.RegistrationSpec<K,V>
- Type Parameters:
K- the type of the key that identifies the valueV- the type of the data value
- Enclosing interface:
- BatchLoaderRegistry
-
Method Summary
Modifier and TypeMethodDescriptionvoidregisterBatchLoader(BiFunction<List<K>, org.dataloader.BatchLoaderEnvironment, reactor.core.publisher.Flux<V>> loader) Register the give batch loading function.voidregisterMappedBatchLoader(BiFunction<Set<K>, org.dataloader.BatchLoaderEnvironment, reactor.core.publisher.Mono<Map<K, V>>> loader) A variant ofregisterBatchLoader(BiFunction)that returns a Map of key-value pairs, which is useful is there aren't values for all keys.Customize the name under which theDataLoaderis registered and can be accessed in the data layer.withOptions(Consumer<org.dataloader.DataLoaderOptions> optionsConsumer) Customize theDataLoaderOptionsto use to create theDataLoaderviaDataLoaderFactory.withOptions(org.dataloader.DataLoaderOptions options) Set theDataLoaderOptionsto use to create theDataLoaderviaDataLoaderFactory.
-
Method Details
-
withName
Customize the name under which theDataLoaderis 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).- Parameters:
name- the name to use- Returns:
- a spec to complete the registration
-
withOptions
BatchLoaderRegistry.RegistrationSpec<K,V> withOptions(Consumer<org.dataloader.DataLoaderOptions> optionsConsumer) Customize theDataLoaderOptionsto use to create theDataLoaderviaDataLoaderFactory.Note: Do not set
DataLoaderOptions.setBatchLoaderContextProvider(BatchLoaderContextProvider)as this will be set later to a provider that returns the context fromExecutionInput.getGraphQLContext(), so that batch loading functions and data fetchers can rely on access to the same context.- Parameters:
optionsConsumer- callback to customize the options, invoked immediately and given access to the options instance- Returns:
- a spec to complete the registration
-
withOptions
Set theDataLoaderOptionsto use to create theDataLoaderviaDataLoaderFactory.Note: Do not set
DataLoaderOptions.setBatchLoaderContextProvider(BatchLoaderContextProvider)as this will be set later to a provider that returns the context fromExecutionInput.getGraphQLContext(), so that batch loading functions and data fetchers can rely on access to the same context.- Parameters:
options- the options to use- Returns:
- a spec to complete the registration
-
registerBatchLoader
void registerBatchLoader(BiFunction<List<K>, org.dataloader.BatchLoaderEnvironment, reactor.core.publisher.Flux<V>> loader) Register the give batch loading function.The values returned from the function must match the order and the number of keys, with
nullfor missing values. Please, seeBatchLoader.- Parameters:
loader- the loader function- See Also:
-
BatchLoader
-
registerMappedBatchLoader
void registerMappedBatchLoader(BiFunction<Set<K>, org.dataloader.BatchLoaderEnvironment, reactor.core.publisher.Mono<Map<K, V>>> loader) A variant ofregisterBatchLoader(BiFunction)that returns a Map of key-value pairs, which is useful is there aren't values for all keys. Please seeMappedBatchLoader.- Parameters:
loader- the loader function- See Also:
-
MappedBatchLoader
-