Package graphql.schema
Class DataFetcherFactories
java.lang.Object
graphql.schema.DataFetcherFactories
A helper for
DataFetcherFactory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> DataFetcherFactory
<T> useDataFetcher
(DataFetcher<T> dataFetcher) Creates aDataFetcherFactory
that always returns the providedDataFetcher
static DataFetcher
<?> wrapDataFetcher
(DataFetcher<?> delegateDataFetcher, BiFunction<DataFetchingEnvironment, Object, Object> mapFunction) This helper function allows you to wrap an existing data fetcher and map the value once it completes.
-
Constructor Details
-
DataFetcherFactories
public DataFetcherFactories()
-
-
Method Details
-
useDataFetcher
Creates aDataFetcherFactory
that always returns the providedDataFetcher
- Type Parameters:
T
- the type of the data fetcher- Parameters:
dataFetcher
- the data fetcher to always return- Returns:
- a data fetcher factory that always returns the provided data fetcher
-
wrapDataFetcher
public static DataFetcher<?> wrapDataFetcher(DataFetcher<?> delegateDataFetcher, BiFunction<DataFetchingEnvironment, Object, Object> mapFunction) This helper function allows you to wrap an existing data fetcher and map the value once it completes. It helps you handle values that might beCompletionStage
returned values as well as plain old objects.- Parameters:
delegateDataFetcher
- the original data fetcher that is present on aGraphQLFieldDefinition
saymapFunction
- the bi function to apply to the original value- Returns:
- a new data fetcher that wraps the provided data fetcher
-