T
- returned result typepublic abstract class QuerydslDataFetcher<T> extends 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 RuntimeWiringConfigurer
that can auto-register repositories
annotated with @GraphQlRepository
.
GraphQlRepository
,
QuerydslPredicateExecutor
,
ReactiveQuerydslPredicateExecutor
,
Predicate
,
QuerydslBinderCustomizer
,
Spring Data Querydsl extensionModifier 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 RuntimeWiringConfigurer |
autoRegistrationConfigurer(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors,
List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors)
Return a
RuntimeWiringConfigurer that installs a
WiringFactory to find queries with a return
type whose name matches to the domain type name of the given repositories
and registers DataFetcher s for them. |
static GraphQLTypeVisitor |
autoRegistrationTypeVisitor(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors,
List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors)
Deprecated.
in favor of
autoRegistrationConfigurer(List, List) |
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)
Prepare a
Predicate from GraphQL request arguments, also applying
any QuerydslBinderCustomizer that may have been configured. |
protected Collection<String> |
buildPropertyPaths(DataFetchingFieldSelectionSet selection,
Class<?> resultType) |
protected boolean |
requiresProjection(Class<?> resultType) |
protected com.querydsl.core.types.Predicate buildPredicate(DataFetchingEnvironment environment)
Predicate
from GraphQL request arguments, also applying
any QuerydslBinderCustomizer
that may have been configured.environment
- contextual info for the GraphQL requestprotected boolean requiresProjection(Class<?> resultType)
protected Collection<String> buildPropertyPaths(DataFetchingFieldSelectionSet selection, 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 RuntimeWiringConfigurer autoRegistrationConfigurer(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors)
RuntimeWiringConfigurer
that installs a
WiringFactory
to find queries with a return
type whose name matches to the domain type name of the given repositories
and registers DataFetcher
s for them.
Note: This applies only to top-level queries and
repositories annotated with @GraphQlRepository
.
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@Deprecated public static GraphQLTypeVisitor autoRegistrationTypeVisitor(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors)
autoRegistrationConfigurer(List, List)
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