Releases: graphql-java/java-dataloader
Releases · graphql-java/java-dataloader
3.0.1
3.0.0
Breaking Changes
- the
CacheMap
signature has been changed to correctly reflect that it is a cache ofCompletableFuture<V>
and not just<V>
Other changes
-
a new
ValueCache
layer has been added to that allows values to be stored in external cache systems such as REDIS or long lived cross request systems like Caffeine -
A new last dispatched time is present on DataLoaders
-
An experimental
ScheduledDataLoaderRegistry
that allows new ways to dispatch dataloaders.
2.2.3
2.2.0
2.1.1
This adds new features into data loader to allow you to write more powerful batch loading functions
The first is returning a Map from batch loader function instead of an ordered list. This suits some use cases much more naturally
MappedBatchLoaderWithContext<Long, User> mapBatchLoader = new MappedBatchLoaderWithContext<Long, User>() {
@Override
public CompletionStage<Map<Long, User>> load(Set<Long> userIds, BatchLoaderEnvironment environment) {
SecurityCtx callCtx = environment.getContext();
return CompletableFuture.supplyAsync(() -> userManager.loadMapOfUsersByIds(callCtx, userIds));
}
};
DataLoader<Long, User> userLoader = DataLoader.newMappedDataLoader(mapBatchLoader);
// ...
The second major change is that context
can now be pushed into batch loading functions allowing you to get user credentials or database details for example
DataLoaderOptions options = DataLoaderOptions.newOptions()
.setBatchLoaderContextProvider(() -> SecurityCtx.getCallingUserCtx());
BatchLoaderWithContext<String, String> batchLoader = new BatchLoaderWithContext<String, String>() {
@Override
public CompletionStage<List<String>> load(List<String> keys, BatchLoaderEnvironment environment) {
SecurityCtx callCtx = environment.getContext();
return callDatabaseForResults(callCtx, keys);
}
};
DataLoader<String, String> loader = DataLoader.newDataLoader(batchLoader, options);