Class DataFetcherFactories

java.lang.Object
graphql.schema.DataFetcherFactories

@PublicApi public class DataFetcherFactories extends Object
A helper for DataFetcherFactory
  • Constructor Details

    • DataFetcherFactories

      public DataFetcherFactories()
  • Method Details

    • useDataFetcher

      public static <T> DataFetcherFactory<T> useDataFetcher(DataFetcher<T> dataFetcher)
      Creates a DataFetcherFactory that always returns the provided DataFetcher
      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 be CompletionStage returned values as well as plain old objects.
      Parameters:
      delegateDataFetcher - the original data fetcher that is present on a GraphQLFieldDefinition say
      mapFunction - the bi function to apply to the original value
      Returns:
      a new data fetcher that wraps the provided data fetcher