@PublicApi public class AsyncDataFetcher<T> extends java.lang.Object implements DataFetcher<java.util.concurrent.CompletableFuture<T>>
Constructor and Description |
---|
AsyncDataFetcher(DataFetcher<T> wrappedDataFetcher) |
AsyncDataFetcher(DataFetcher<T> wrappedDataFetcher,
java.util.concurrent.Executor executor) |
Modifier and Type | Method and Description |
---|---|
static <T> AsyncDataFetcher<T> |
async(DataFetcher<T> wrappedDataFetcher)
A factory method for creating asynchronous data fetchers so that when used with
static imports allows more readable code such as:
|
static <T> AsyncDataFetcher<T> |
async(DataFetcher<T> wrappedDataFetcher,
java.util.concurrent.Executor executor)
A factory method for creating asynchronous data fetchers and setting the
Executor they run in so that when used with static imports allows
more readable code such as: |
java.util.concurrent.CompletableFuture<T> |
get(DataFetchingEnvironment environment)
This is called by the graphql engine to fetch the value.
|
public AsyncDataFetcher(DataFetcher<T> wrappedDataFetcher)
public AsyncDataFetcher(DataFetcher<T> wrappedDataFetcher, java.util.concurrent.Executor executor)
public static <T> AsyncDataFetcher<T> async(DataFetcher<T> wrappedDataFetcher)
.dataFetcher(async(fooDataFetcher))
By default this will run in the ForkJoinPool.commonPool()
. You can set
your own Executor
with async(DataFetcher, Executor)
T
- the type of datawrappedDataFetcher
- the data fetcher to run asynchronouslyDataFetcher
that will run the wrappedDataFetcher asynchronouslypublic static <T> AsyncDataFetcher<T> async(DataFetcher<T> wrappedDataFetcher, java.util.concurrent.Executor executor)
Executor
they run in so that when used with static imports allows
more readable code such as:
.dataFetcher(async(fooDataFetcher, fooExecutor))
T
- the type of datawrappedDataFetcher
- the data fetcher to run asynchronouslyexecutor
- the executor to run the asynchronous data fetcher inDataFetcher
that will run the wrappedDataFetcher asynchronously in
the given Executor
public java.util.concurrent.CompletableFuture<T> get(DataFetchingEnvironment environment)
DataFetcher
DataFetchingEnvironment
is a composite
context object that tells you all you need to know about how to fetch a data value in graphql type terms.get
in interface DataFetcher<java.util.concurrent.CompletableFuture<T>>
environment
- this is the data fetching environment which contains all the context you need to fetch a valueDataFetcherResult