use of org.dataloader.DataLoaderRegistry in project graphql-java by graphql-java.
the class BatchCompare method dataLoaderRun.
void dataLoaderRun() {
System.out.println("=== AsyncExecutionStrategy with DataLoader ===");
GraphQLSchema schema = buildDataLoaderSchema();
DataLoaderRegistry dataLoaderRegistry = new DataLoaderRegistry();
dataLoaderRegistry.register("departments", BatchCompareDataFetchers.departmentsForShopDataLoader);
dataLoaderRegistry.register("products", BatchCompareDataFetchers.productsForDepartmentDataLoader);
GraphQL graphQL = GraphQL.newGraphQL(schema).instrumentation(new DataLoaderDispatcherInstrumentation(dataLoaderRegistry)).build();
ExecutionInput executionInput = ExecutionInput.newExecutionInput().query("query { shops { id name departments { id name products { id name } } } }").build();
ExecutionResult result = graphQL.execute(executionInput);
System.out.println("\nExecutionResult: " + result.toSpecification());
}
Aggregations