Interface BatchLoaderRegistry.RegistrationSpec<K,V>

Type Parameters:
K - the type of the key that identifies the value
V - the type of the data value
Enclosing interface:
BatchLoaderRegistry

public static interface BatchLoaderRegistry.RegistrationSpec<K,V>
Spec to complete the registration of a batch loading function.
  • Method Details

    • withName

      Customize the name under which the DataLoader is registered and can be accessed in the data layer.

      By default, this is the full class name of the value type, if the value type is specified via BatchLoaderRegistry.forTypePair(Class, Class).

      Parameters:
      name - the name to use
      Returns:
      a spec to complete the registration
    • withOptions

      BatchLoaderRegistry.RegistrationSpec<K,V> withOptions(Consumer<org.dataloader.DataLoaderOptions> optionsConsumer)
      Customize the DataLoaderOptions to use to create the DataLoader via DataLoaderFactory.

      Note: Do not set DataLoaderOptions.setBatchLoaderContextProvider(BatchLoaderContextProvider) as this will be set later to a provider that returns the context from ExecutionInput.getGraphQLContext(), so that batch loading functions and data fetchers can rely on access to the same context.

      Parameters:
      optionsConsumer - callback to customize the options, invoked immediately and given access to the options instance
      Returns:
      a spec to complete the registration
    • withOptions

      BatchLoaderRegistry.RegistrationSpec<K,V> withOptions(org.dataloader.DataLoaderOptions options)
      Set the DataLoaderOptions to use to create the DataLoader via DataLoaderFactory.

      Note: Do not set DataLoaderOptions.setBatchLoaderContextProvider(BatchLoaderContextProvider) as this will be set later to a provider that returns the context from ExecutionInput.getGraphQLContext(), so that batch loading functions and data fetchers can rely on access to the same context.

      Parameters:
      options - the options to use
      Returns:
      a spec to complete the registration
    • registerBatchLoader

      void registerBatchLoader(BiFunction<List<K>,org.dataloader.BatchLoaderEnvironment,reactor.core.publisher.Flux<V>> loader)
      Register the give batch loading function.

      The values returned from the function must match the order and the number of keys, with null for missing values. Please, see BatchLoader.

      Parameters:
      loader - the loader function
      See Also:
      • BatchLoader
    • registerMappedBatchLoader

      void registerMappedBatchLoader(BiFunction<Set<K>,org.dataloader.BatchLoaderEnvironment,reactor.core.publisher.Mono<Map<K,V>>> loader)
      A variant of registerBatchLoader(BiFunction) that returns a Map of key-value pairs, which is useful is there aren't values for all keys. Please see MappedBatchLoader.
      Parameters:
      loader - the loader function
      See Also:
      • MappedBatchLoader