Class FindByIdsDataLoader

java.lang.Object
org.autumnframework.service.graphql.dataloader.FindByIdsDataLoader

public class FindByIdsDataLoader extends Object
Class to give you a head start on creating a graphql dataloader for the default autumn services and mappers
  • Constructor Details

    • FindByIdsDataLoader

      public FindByIdsDataLoader()
  • Method Details

    • findByIds

      public static <T extends Identifiable> reactor.core.publisher.Mono<Map<UUID,T>> findByIds(Set<UUID> ids, ReadFindByIdsService<T> service)
      Basic find by ids method, using a ReadFindByIdsService <T> to call findByIds for a set of UUIDs, returning a map of UUID -> T.
      Type Parameters:
      T - The expected return type
      Parameters:
      ids - A set of IDs of type UUID
      service - The service to use in finding the list of <T> (it will call service.findByIds(ids)
      Returns:
      a Map of <UUID>, <T> with each <T> being the singular return type of the findByIds method as identified by the UUID key
    • findByIds

      public static <T extends Identifiable> reactor.core.publisher.Mono<Map<UUID,T>> findByIds(Set<UUID> ids, ReadFindByIdsService<T> service, Function<T,UUID> keyExtractor)
      Find by ids method, using a ReadFindByIdsService<T> to call findByIds for a set of UUIDs, returning a map of UUID -> T. This version uses a specified method to extract the keys (use this to specify a method that differs from T.getId()).
      Type Parameters:
      T - The expected return type
      Parameters:
      ids - A set of IDs of type UUID
      keyExtractor - A method to extract the UUID key from the received objects
      service - The service to use in finding the list of <T> (it will call service.findByIds(ids)
      Returns:
      a Map of <UUID>, <T> with each <T> being the singular return type of the findByIds method as identified by the UUID key
    • findByIds

      public static <T extends Identifiable> reactor.core.publisher.Mono<Map<UUID,T>> findByIds(Set<UUID> keys, Function<List<UUID>,Collection<T>> serviceMethod)
      Find by ids method, using a specified method taking a List of UUID and returning a Collection of T, returning a map of UUID -> T. This version uses a specified method to retrieve the collection of T.
      Type Parameters:
      T - extends Identifiable
      Parameters:
      keys - Set of ids to use in the service method called
      serviceMethod - The method to call using the keys received
      Returns:
      a Map of <R>, <T> with each <T> being the singular return type of the method as identified by key <R>
    • findByKeys

      public static <T extends Identifiable, R> reactor.core.publisher.Mono<Map<R,T>> findByKeys(Set<R> keys, Function<List<R>,Collection<T>> serviceMethod, Function<T,R> keyExtractor)
      Basic find by keys method, using a specified method taking a List of R and returning a Collection of T, returning a map of R -> T. This version uses a specified method to retrieve the collection of T and a specified method to extract the keys.
      Type Parameters:
      T - extends Identifiable
      R - the key type
      Parameters:
      keys - Set of ids to use in the service method called
      serviceMethod - The method to call using the keys received
      keyExtractor - A method to extract the key from the received objects <R>
      Returns:
      a Map of <R>, <T> with each <T> being the singular return type of the method as identified by key <R>
    • findByKeys

      public static <T extends Identifiable, C extends Iterable<R>, R> reactor.core.publisher.Mono<Map<R,T>> findByKeys(Set<R> keys, Function<C,Collection<T>> serviceMethod, Function<T,R> keyExtractor, Function<Set<R>,C> methodArgumentCreator, Function<List<R>,C> listToMethodArgumentCreator)
      Find by keys method that allows you to specify methods to convert a set and list of keys to the expected parameter type of the service method to use in retrieving the results.
      Type Parameters:
      T - extends Identifiable
      C - extends Iterable <R>
      R - the key type
      Parameters:
      keys - Set of ids to use in the service method called
      serviceMethod - The method to call using the keys received
      keyExtractor - A method to extract the key from the received objects <R>
      methodArgumentCreator - A way to convert a Set of <R> to the Collection type accepted by serviceMethod
      listToMethodArgumentCreator - A way to convert a List of <R> to the Collection type accepted by serviceMethod
      Returns:
      a Map of <R>, <T> with each <T> being the singular return type of the method as identified by key <R>