Skip to content

Make NoOpStatisticsCollector to be default StatisticsCollector #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.dataloader.DataLoaderOptions;
import org.dataloader.DataLoaderRegistry;
import org.dataloader.MappedBatchLoaderWithContext;
import org.dataloader.stats.NoOpStatisticsCollector;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.context.ContextView;
Expand Down Expand Up @@ -68,7 +69,8 @@ public <K, V> RegistrationSpec<K, V> forName(String name) {
@Override
public void registerDataLoaders(DataLoaderRegistry registry, GraphQLContext context) {
BatchLoaderContextProvider contextProvider = () -> context;
DataLoaderOptions defaultOptions = DataLoaderOptions.newOptions().setBatchLoaderContextProvider(contextProvider);
DataLoaderOptions defaultOptions = DataLoaderOptions.newOptions().setBatchLoaderContextProvider(contextProvider)
.setStatisticsCollector(NoOpStatisticsCollector::new);
for (ReactorBatchLoader<?, ?> loader : this.loaders) {
DataLoaderOptions options = loader.getOptionsOrDefault(contextProvider, defaultOptions);
DataLoader<?, ?> dataLoader = DataLoaderFactory.newDataLoader(loader, options);
Expand Down Expand Up @@ -117,7 +119,9 @@ public RegistrationSpec<K, V> withName(String name) {

@Override
public RegistrationSpec<K, V> withOptions(Consumer<DataLoaderOptions> optionsConsumer) {
this.options = (this.options != null ? this.options : DataLoaderOptions.newOptions());
this.options = (this.options != null ?
this.options :
DataLoaderOptions.newOptions().setStatisticsCollector(NoOpStatisticsCollector::new));
optionsConsumer.accept(this.options);
return this;
}
Expand Down