Annotation Type BatchMapping


@Retention(CLASS) @Target(METHOD) public @interface BatchMapping

Resolves a field for every object in a list with one call, as in Spring for GraphQL: the answer to the N+1 problem of a SchemaMapping that would otherwise query once per object.

The method takes a List of the sources and returns either a Map from each source to its value, or a List with one value per source in order.

@BatchMapping(typeName = "Book")
public Map<Book, Author> author(List<Book> books) { ... }
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The field's name; empty means the method's name.
    The object type the field belongs to; empty means the class's @SchemaMapping type.
    The field's name; empty means the method's name.
  • Element Details

    • typeName

      String typeName
      The object type the field belongs to; empty means the class's @SchemaMapping type.
      Default:
      ""
    • value

      String value
      The field's name; empty means the method's name. Same as field().
      Default:
      ""
    • field

      String field
      The field's name; empty means the method's name. Same as value().
      Default:
      ""