Search in sources :

Example 1 with NoOpStatisticsCollector

use of org.dataloader.stats.NoOpStatisticsCollector in project spring-graphql by spring-projects.

the class DefaultBatchLoaderRegistryTests method batchLoaderWithCustomNameAndOptions.

@Test
void batchLoaderWithCustomNameAndOptions() {
    String name = "myLoader";
    StatisticsCollector collector = new NoOpStatisticsCollector();
    this.batchLoaderRegistry.forName(name).withOptions(options -> options.setStatisticsCollector(() -> collector)).registerBatchLoader((keys, environment) -> Flux.empty());
    this.batchLoaderRegistry.registerDataLoaders(this.dataLoaderRegistry, GraphQLContext.newContext().build());
    Map<String, DataLoader<?, ?>> map = dataLoaderRegistry.getDataLoadersMap();
    assertThat(map).hasSize(1).containsKey(name);
    assertThat(map.get(name).getStatistics()).isSameAs(collector.getStatistics());
}
Also used : NoOpStatisticsCollector(org.dataloader.stats.NoOpStatisticsCollector) DataLoaderRegistry(org.dataloader.DataLoaderRegistry) ContextView(reactor.util.context.ContextView) StatisticsCollector(org.dataloader.stats.StatisticsCollector) Context(reactor.util.context.Context) BookSource(org.springframework.graphql.BookSource) NoOpStatisticsCollector(org.dataloader.stats.NoOpStatisticsCollector) Mono(reactor.core.publisher.Mono) DataLoader(org.dataloader.DataLoader) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Book(org.springframework.graphql.Book) ExecutionInput(graphql.ExecutionInput) Test(org.junit.jupiter.api.Test) Flux(reactor.core.publisher.Flux) GraphQLContext(graphql.GraphQLContext) Map(java.util.Map) AssertionsForInterfaceTypes.assertThat(org.assertj.core.api.AssertionsForInterfaceTypes.assertThat) DataLoader(org.dataloader.DataLoader) StatisticsCollector(org.dataloader.stats.StatisticsCollector) NoOpStatisticsCollector(org.dataloader.stats.NoOpStatisticsCollector) Test(org.junit.jupiter.api.Test)

Aggregations

ExecutionInput (graphql.ExecutionInput)1 GraphQLContext (graphql.GraphQLContext)1 Map (java.util.Map)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Function (java.util.function.Function)1 AssertionsForInterfaceTypes.assertThat (org.assertj.core.api.AssertionsForInterfaceTypes.assertThat)1 DataLoader (org.dataloader.DataLoader)1 DataLoaderRegistry (org.dataloader.DataLoaderRegistry)1 NoOpStatisticsCollector (org.dataloader.stats.NoOpStatisticsCollector)1 StatisticsCollector (org.dataloader.stats.StatisticsCollector)1 Test (org.junit.jupiter.api.Test)1 Book (org.springframework.graphql.Book)1 BookSource (org.springframework.graphql.BookSource)1 Flux (reactor.core.publisher.Flux)1 Mono (reactor.core.publisher.Mono)1 Context (reactor.util.context.Context)1 ContextView (reactor.util.context.ContextView)1