T
- returned result typepublic abstract class QuerydslDataFetcher<T> extends Object
DataFetcher
using repositories through Querydsl.
Exposes builders accepting QuerydslPredicateExecutor
or
ReactiveQuerydslPredicateExecutor
that support customization of bindings
and interface- and DTO projections. Instances can be created through a
builder
to query for
QuerydslDataFetcher.Builder.single()
or QuerydslDataFetcher.Builder.many()
objects.
Example:
interface BookRepository extends Repository<Book, String>, QuerydslPredicateExecutor<Book>{} TypeRuntimeWiring wiring = … ; BookRepository repository = … ; wiring.dataFetcher("books", QuerydslDataFetcher.builder(repository).many()) .dataFetcher("book", QuerydslDataFetcher.builder(repository).single());
DataFetcher
returning reactive types such as Mono
and Flux
can be constructed from a ReactiveQuerydslPredicateExecutor
using
builder
.
For example:
interface BookRepository extends Repository<Book, String>, ReactiveQuerydslPredicateExecutor<Book>{} TypeRuntimeWiring wiring = …; BookRepository repository = …; wiring.dataFetcher("books", QuerydslDataFetcher.builder(repository).many()) .dataFetcher("book", QuerydslDataFetcher.builder(repository).single());
QuerydslPredicateExecutor
,
ReactiveQuerydslPredicateExecutor
,
Predicate
,
QuerydslBinderCustomizer
Modifier and Type | Class and Description |
---|---|
static class |
QuerydslDataFetcher.Builder<T,R>
Builder for a Querydsl-based
DataFetcher . |
static class |
QuerydslDataFetcher.ReactiveBuilder<T,R>
Builder for a reactive Querydsl-based
DataFetcher . |
Modifier and Type | Method and Description |
---|---|
static <T> QuerydslDataFetcher.Builder<T,T> |
builder(org.springframework.data.querydsl.QuerydslPredicateExecutor<T> executor)
Create a new
QuerydslDataFetcher.Builder accepting QuerydslPredicateExecutor
to build a DataFetcher . |
static <T> QuerydslDataFetcher.ReactiveBuilder<T,T> |
builder(org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<T> executor)
Create a new
QuerydslDataFetcher.ReactiveBuilder accepting
ReactiveQuerydslPredicateExecutor to build a reactive DataFetcher . |
protected com.querydsl.core.types.Predicate |
buildPredicate(DataFetchingEnvironment environment) |
public static <T> QuerydslDataFetcher.Builder<T,T> builder(org.springframework.data.querydsl.QuerydslPredicateExecutor<T> executor)
QuerydslDataFetcher.Builder
accepting QuerydslPredicateExecutor
to build a DataFetcher
.T
- result typeexecutor
- the repository object to usepublic static <T> QuerydslDataFetcher.ReactiveBuilder<T,T> builder(org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<T> executor)
QuerydslDataFetcher.ReactiveBuilder
accepting
ReactiveQuerydslPredicateExecutor
to build a reactive DataFetcher
.T
- result typeexecutor
- the repository object to useprotected com.querydsl.core.types.Predicate buildPredicate(DataFetchingEnvironment environment)