Package graphql.schema
Class DataFetcherFactories
- java.lang.Object
-
- graphql.schema.DataFetcherFactories
-
@PublicApi public class DataFetcherFactories extends java.lang.Object
A helper forDataFetcherFactory
-
-
Constructor Summary
Constructors Constructor Description DataFetcherFactories()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> DataFetcherFactory<T>useDataFetcher(DataFetcher<T> dataFetcher)Creates aDataFetcherFactorythat always returns the providedDataFetcherstatic DataFetcherwrapDataFetcher(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.
-
-
-
Method Detail
-
useDataFetcher
public static <T> DataFetcherFactory<T> useDataFetcher(DataFetcher<T> dataFetcher)
Creates aDataFetcherFactorythat 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, 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. It helps you handle values that might beCompletionStagereturned values as well as plain old objects.- Parameters:
delegateDataFetcher- the original data fetcher that is present on aGraphQLFieldDefinitionsaymapFunction- the bi function to apply to the original value- Returns:
- a new data fetcher that wraps the provided data fetcher
-
-