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,
Spring Data Querydsl extension| 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) |
static GraphQLTypeVisitor |
registrationTypeVisitor(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors,
List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors)
Create a
GraphQLTypeVisitor that finds queries with a return type
whose name matches to the domain type name of the given repositories and
registers DataFetchers for those queries. |
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 usepublic static GraphQLTypeVisitor registrationTypeVisitor(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors)
GraphQLTypeVisitor that finds queries with a return type
whose name matches to the domain type name of the given repositories and
registers DataFetchers for those queries.
Note: currently, this method will match only to queries under the top-level "Query" type in the GraphQL schema.
executors - repositories to consider for registrationreactiveExecutors - reactive repositories to consider for registrationprotected com.querydsl.core.types.Predicate buildPredicate(DataFetchingEnvironment environment)