T - returned result typepublic abstract class QuerydslDataFetcher<T>
extends java.lang.Object
DataFetcher from a Querydsl repository.
To create an instance, use one of the following:
For example:
interface BookRepository extends
Repository<Book, String>, QuerydslPredicateExecutor<Book>{}
TypeRuntimeWiring wiring = … ;
BookRepository repository = … ;
DataFetcher<?> forMany =
wiring.dataFetcher("books", QuerydslDataFetcher.builder(repository).many());
DataFetcher<?> forSingle =
wiring.dataFetcher("book", QuerydslDataFetcher.builder(repository).single());
See QuerydslDataFetcher.Builder and QuerydslDataFetcher.ReactiveBuilder methods for further
options on GraphQL Query argument to Querydsl Predicate binding customizations,
result projections, and sorting.
QuerydslDataFetcher exposes
a GraphQLTypeVisitor that can auto-register repositories annotated with
@GraphQlRepository.
GraphQlRepository,
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 graphql.schema.GraphQLTypeVisitor |
autoRegistrationTypeVisitor(java.util.List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors,
java.util.List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors)
Return a
GraphQLTypeVisitor that auto-registers the given
Querydsl repositories for queries that do not already have a registered
DataFetcher and whose return type matches the simple name of the
repository domain type. |
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(graphql.schema.DataFetchingEnvironment environment)
Prepare a
Predicate from GraphQL query arguments, also applying
any QuerydslBinderCustomizer that may have been configured. |
protected java.util.Collection<java.lang.String> |
buildPropertyPaths(graphql.schema.DataFetchingFieldSelectionSet selection,
java.lang.Class<?> resultType) |
protected boolean |
requiresProjection(java.lang.Class<?> resultType) |
protected com.querydsl.core.types.Predicate buildPredicate(graphql.schema.DataFetchingEnvironment environment)
Predicate from GraphQL query arguments, also applying
any QuerydslBinderCustomizer that may have been configured.environment - contextual info for the GraphQL queryprotected boolean requiresProjection(java.lang.Class<?> resultType)
protected java.util.Collection<java.lang.String> buildPropertyPaths(graphql.schema.DataFetchingFieldSelectionSet selection,
java.lang.Class<?> resultType)
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 graphql.schema.GraphQLTypeVisitor autoRegistrationTypeVisitor(java.util.List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors,
java.util.List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors)
GraphQLTypeVisitor that auto-registers the given
Querydsl repositories for queries that do not already have a registered
DataFetcher and whose return type matches the simple name of the
repository domain type.
Note: Auto-registration applies only to
@GraphQlRepository-annotated repositories.
If a repository is also an instance of QuerydslBinderCustomizer,
this is transparently detected and applied through the
QuerydslDataFetcher builder methods.
executors - repositories to consider for registrationreactiveExecutors - reactive repositories to consider for registration