Search in sources :

Example 1 with ExecutorServiceExecutionStrategy

use of graphql.execution.ExecutorServiceExecutionStrategy in project graphql-java by graphql-java.

the class ExecutionExamples method exampleExecutorServiceExecutionStrategy.

private void exampleExecutorServiceExecutionStrategy() {
    ExecutorService executorService = new ThreadPoolExecutor(2, /* core pool size 2 thread */
    2, /* max pool size 2 thread */
    30, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new ThreadPoolExecutor.CallerRunsPolicy());
    GraphQL graphQL = GraphQL.newGraphQL(StarWarsSchema.starWarsSchema).queryExecutionStrategy(new ExecutorServiceExecutionStrategy(executorService)).mutationExecutionStrategy(new AsyncSerialExecutionStrategy()).build();
}
Also used : GraphQL(graphql.GraphQL) ExecutorService(java.util.concurrent.ExecutorService) ExecutorServiceExecutionStrategy(graphql.execution.ExecutorServiceExecutionStrategy) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) AsyncSerialExecutionStrategy(graphql.execution.AsyncSerialExecutionStrategy)

Example 2 with ExecutorServiceExecutionStrategy

use of graphql.execution.ExecutorServiceExecutionStrategy in project graphql-java by graphql-java.

the class ReadmeExamples method executionStrategies.

void executionStrategies() {
    ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2, /* core pool size 2 thread */
    2, /* max pool size 2 thread */
    30, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new ThreadPoolExecutor.CallerRunsPolicy());
    GraphQL graphQL = GraphQL.newGraphQL(StarWarsSchema.starWarsSchema).queryExecutionStrategy(new ExecutorServiceExecutionStrategy(threadPoolExecutor)).mutationExecutionStrategy(new AsyncExecutionStrategy()).subscriptionExecutionStrategy(new AsyncExecutionStrategy()).build();
}
Also used : GraphQL(graphql.GraphQL) ExecutorServiceExecutionStrategy(graphql.execution.ExecutorServiceExecutionStrategy) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) AsyncExecutionStrategy(graphql.execution.AsyncExecutionStrategy)

Aggregations

GraphQL (graphql.GraphQL)2 ExecutorServiceExecutionStrategy (graphql.execution.ExecutorServiceExecutionStrategy)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 AsyncExecutionStrategy (graphql.execution.AsyncExecutionStrategy)1 AsyncSerialExecutionStrategy (graphql.execution.AsyncSerialExecutionStrategy)1 ExecutorService (java.util.concurrent.ExecutorService)1