bbakerman
released this
This adds getIfPresent and getIfCompleted methods as well as a computeIfAbsent on DataLoaderRegistry for lazy loaders
Assets
2
This adds the ability to be passed a list of context load objects per batch key as well as a map of them
Assets
2
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);
Assets
2
This release is borked. DO NOT USE. Use 2.1.1 instead
Assets
2
-
This fixes a bug where calling load while caching is disabled means the batch loader should get duplicate batch calls.
-
Also the synchronized code policy was changed
Assets
2
- Adds new statistics capability so you can track what is happening inside your data loaders
Assets
2
- #9 - add Try support
- This changes the DataLoader registry so its a named map of loaders
- Removed the dependency on graphql-java
- Removed the graphql dispatching Instrumentation (since it will be moved to graphql-java)
Assets
2
- There is now graphql
Instrumentationsupport that ensures dataloader is dispatched as a graphql query executes