Search in sources :

Example 1 with AsyncExecutionStrategy

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

the class DataLoaderDispatcherInstrumentation method beginExecuteOperation.

@Override
public InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters) {
    ExecutionStrategy queryStrategy = parameters.getExecutionContext().getQueryStrategy();
    if (!(queryStrategy instanceof AsyncExecutionStrategy)) {
        CallStack callStack = parameters.getInstrumentationState();
        callStack.setAggressivelyBatching(false);
    }
    return whenDispatched((result) -> dispatch());
}
Also used : ExecutionStrategy(graphql.execution.ExecutionStrategy) AsyncExecutionStrategy(graphql.execution.AsyncExecutionStrategy) AsyncExecutionStrategy(graphql.execution.AsyncExecutionStrategy)

Example 2 with AsyncExecutionStrategy

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

the class ExecutionExamples method exceptionHandler.

private void exceptionHandler() {
    DataFetcherExceptionHandler handler = new DataFetcherExceptionHandler() {

        @Override
        public void accept(DataFetcherExceptionHandlerParameters handlerParameters) {
        // 
        // do your custom handling here.  The parameters have all you need
        }
    };
    ExecutionStrategy executionStrategy = new AsyncExecutionStrategy(handler);
}
Also used : DataFetcherExceptionHandler(graphql.execution.DataFetcherExceptionHandler) DataFetcherExceptionHandlerParameters(graphql.execution.DataFetcherExceptionHandlerParameters) ExecutionStrategy(graphql.execution.ExecutionStrategy) ExecutorServiceExecutionStrategy(graphql.execution.ExecutorServiceExecutionStrategy) AsyncExecutionStrategy(graphql.execution.AsyncExecutionStrategy) AsyncSerialExecutionStrategy(graphql.execution.AsyncSerialExecutionStrategy) AsyncExecutionStrategy(graphql.execution.AsyncExecutionStrategy)

Example 3 with AsyncExecutionStrategy

use of graphql.execution.AsyncExecutionStrategy 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

AsyncExecutionStrategy (graphql.execution.AsyncExecutionStrategy)3 ExecutionStrategy (graphql.execution.ExecutionStrategy)2 ExecutorServiceExecutionStrategy (graphql.execution.ExecutorServiceExecutionStrategy)2 GraphQL (graphql.GraphQL)1 AsyncSerialExecutionStrategy (graphql.execution.AsyncSerialExecutionStrategy)1 DataFetcherExceptionHandler (graphql.execution.DataFetcherExceptionHandler)1 DataFetcherExceptionHandlerParameters (graphql.execution.DataFetcherExceptionHandlerParameters)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1