Package graphql.schema
Class AsyncDataFetcher<T>
java.lang.Object
graphql.schema.AsyncDataFetcher<T>
- All Implemented Interfaces:
DataFetcher<CompletableFuture<T>>
@PublicApi
public class AsyncDataFetcher<T>
extends Object
implements DataFetcher<CompletableFuture<T>>
A modifier type that indicates the underlying data fetcher is run asynchronously
-
Constructor Summary
ConstructorsConstructorDescriptionAsyncDataFetcher(DataFetcher<T> wrappedDataFetcher) AsyncDataFetcher(DataFetcher<T> wrappedDataFetcher, Executor executor) -
Method Summary
Modifier and TypeMethodDescriptionstatic <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, Executor executor) A factory method for creating asynchronous data fetchers and setting theExecutorthey run in so that when used with static imports allows more readable code such as:get(DataFetchingEnvironment environment) This is called by the graphql engine to fetch the value.
-
Constructor Details
-
AsyncDataFetcher
-
AsyncDataFetcher
-
-
Method Details
-
async
A factory method for creating asynchronous data fetchers so that when used with static imports allows more readable code such as:.dataFetcher(async(fooDataFetcher))By default this will run in the
ForkJoinPool.commonPool(). You can set your ownExecutorwithasync(DataFetcher, Executor)- Type Parameters:
T- the type of data- Parameters:
wrappedDataFetcher- the data fetcher to run asynchronously- Returns:
- a
DataFetcherthat will run the wrappedDataFetcher asynchronously
-
async
A factory method for creating asynchronous data fetchers and setting theExecutorthey run in so that when used with static imports allows more readable code such as:.dataFetcher(async(fooDataFetcher, fooExecutor))- Type Parameters:
T- the type of data- Parameters:
wrappedDataFetcher- the data fetcher to run asynchronouslyexecutor- the executor to run the asynchronous data fetcher in- Returns:
- a
DataFetcherthat will run the wrappedDataFetcher asynchronously in the givenExecutor
-
getWrappedDataFetcher
-
getExecutor
-
get
Description copied from interface:DataFetcherThis is called by the graphql engine to fetch the value. TheDataFetchingEnvironmentis a composite context object that tells you all you need to know about how to fetch a data value in graphql type terms.- Specified by:
getin interfaceDataFetcher<T>- Parameters:
environment- this is the data fetching environment which contains all the context you need to fetch a value- Returns:
- a value of type T. May be wrapped in a
DataFetcherResult
-