@PublicApi public class DataFetcherFactories extends java.lang.Object
DataFetcherFactory
Constructor and Description |
---|
DataFetcherFactories() |
Modifier and Type | Method and Description |
---|---|
static <T> DataFetcherFactory<T> |
useDataFetcher(DataFetcher<T> dataFetcher)
Creates a
DataFetcherFactory that always returns the provided DataFetcher |
static DataFetcher |
wrapDataFetcher(DataFetcher delegateDataFetcher,
java.util.function.BiFunction<DataFetchingEnvironment,java.lang.Object,java.lang.Object> mapFunction)
This helper function allows you to wrap an existing data fetcher and map the value once it completes.
|
public static <T> DataFetcherFactory<T> useDataFetcher(DataFetcher<T> dataFetcher)
DataFetcherFactory
that always returns the provided DataFetcher
T
- the type of the data fetcherdataFetcher
- the data fetcher to always returnpublic static DataFetcher wrapDataFetcher(DataFetcher delegateDataFetcher, java.util.function.BiFunction<DataFetchingEnvironment,java.lang.Object,java.lang.Object> mapFunction)
CompletionStage
returned values as well as plain old objects.delegateDataFetcher
- the original data fetcher that is present on a GraphQLFieldDefinition
saymapFunction
- the bi function to apply to the original value