Class QuerydslDataFetcher.Builder<T,R>

java.lang.Object
org.springframework.graphql.data.query.QuerydslDataFetcher.Builder<T,R>
Type Parameters:
T - domain type
R - result type
Enclosing class:
QuerydslDataFetcher<T>

public static class QuerydslDataFetcher.Builder<T,R> extends Object
Builder for a Querydsl-based DataFetcher. Note that builder instances are immutable and return a new instance of the builder when calling configuration methods.
  • Method Details

    • projectAs

      public <P> QuerydslDataFetcher.Builder<T,P> projectAs(Class<P> projectionType)
      Project results returned from the QuerydslPredicateExecutor into the target projectionType. Projection types can be either interfaces with property getters to expose or regular classes outside the entity type hierarchy for DTO projections.
      Parameters:
      projectionType - projection type
      Returns:
      a new QuerydslDataFetcher.Builder instance with all previously configured options and projectionType applied
    • cursorStrategy

      public QuerydslDataFetcher.Builder<T,R> cursorStrategy(@Nullable CursorStrategy<org.springframework.data.domain.ScrollPosition> cursorStrategy)
      Configure strategy for decoding a cursor from a paginated request.

      By default, this is ScrollPositionCursorStrategy with CursorEncoder.base64() encoding.

      Parameters:
      cursorStrategy - the strategy to use
      Returns:
      a new QuerydslDataFetcher.Builder instance with all previously configured options and Sort applied
      Since:
      1.2.0
    • defaultScrollSubrange

      public QuerydslDataFetcher.Builder<T,R> defaultScrollSubrange(int defaultCount, Function<Boolean,org.springframework.data.domain.ScrollPosition> defaultPosition)
      Configure a default scroll count to use, and function to return a default ScrollPosition for forward vs backward pagination.

      For offset scrolling, use ScrollPosition.offset() to scroll from the beginning. Currently, it is not possible to go back from the end.

      For keyset scrolling, use ScrollPosition.keyset() to scroll from the beginning, or KeysetScrollPosition.reverse() the same to go back from the end.

      By default a count of 20 and ScrollPosition.offset() are used.

      Since:
      1.2.5
    • defaultScrollSubrange

      @Deprecated(since="1.2.5", forRemoval=true) public QuerydslDataFetcher.Builder<T,R> defaultScrollSubrange(@Nullable ScrollSubrange defaultSubrange)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Configure a ScrollSubrange to use when a paginated request does not specify a cursor and/or a count of items.

      By default, this is ScrollPosition.offset() with a count of 20.

      Returns:
      a new QuerydslDataFetcher.Builder instance
      Since:
      1.2.0
    • sortBy

      public QuerydslDataFetcher.Builder<T,R> sortBy(org.springframework.data.domain.Sort sort)
      Apply a Sort order.
      Parameters:
      sort - the default sort order
      Returns:
      a new QuerydslDataFetcher.Builder instance with all previously configured options and Sort applied
    • customizer

      public QuerydslDataFetcher.Builder<T,R> customizer(org.springframework.data.querydsl.binding.QuerydslBinderCustomizer<? extends com.querydsl.core.types.EntityPath<T>> customizer)
      Apply a QuerydslBinderCustomizer.

      If a Querydsl repository implements QuerydslBinderCustomizer itself, this is automatically detected and applied during auto-registration. For manual registration, you will need to use this method to apply it.

      Parameters:
      customizer - to customize the binding of the GraphQL request to Querydsl Predicate
      Returns:
      a new QuerydslDataFetcher.Builder instance with all previously configured options and QuerydslBinderCustomizer applied
    • single

      public DataFetcher<R> single()
      Build a DataFetcher to fetch single object instances.
    • many

      public DataFetcher<Iterable<R>> many()
      Build a DataFetcher to fetch many object instances.
    • scrollable

      public DataFetcher<Iterable<R>> scrollable()
      Build a DataFetcher that scrolls and returns Window.
      Since:
      1.2.0