Class DataFetcherFactories

    • Constructor Detail

      • DataFetcherFactories

        public DataFetcherFactories()
    • Method Detail

      • 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,
                                                  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 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