use of graphql.ExecutionInput in project graphql-java by graphql-java.
the class ExecutionExamples method simpleAsyncQueryExecution.
@SuppressWarnings("Convert2MethodRef")
private void simpleAsyncQueryExecution() throws Exception {
GraphQL graphQL = buildSchema();
ExecutionInput executionInput = ExecutionInput.newExecutionInput().query("query { hero { name } }").build();
CompletableFuture<ExecutionResult> promise = graphQL.executeAsync(executionInput);
promise.thenAccept(executionResult -> {
// here you might send back the results as JSON over HTTP
encodeResultToJsonAndSendResponse(executionResult);
});
promise.join();
}
use of graphql.ExecutionInput 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