Class QuerydslDataFetcher<T>
- Type Parameters:
T
- returned result type
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
.
- Since:
- 1.0.0
- Author:
- Mark Paluch, Rossen Stoyanchev
- See Also:
-
GraphQlRepository
QuerydslPredicateExecutor
ReactiveQuerydslPredicateExecutor
Predicate
QuerydslBinderCustomizer
- Spring Data Querydsl extension
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder for a Querydsl-basedDataFetcher
.static interface
Callback interface that can be used to customize QuerydslDataFetcherQuerydslDataFetcher.Builder
to change its configuration.static class
Builder for a reactive Querydsl-basedDataFetcher
.static interface
Callback interface that can be used to customize QuerydslDataFetcherQuerydslDataFetcher.ReactiveBuilder
to change its configuration. -
Method Summary
Modifier and TypeMethodDescriptionstatic RuntimeWiringConfigurer
autoRegistrationConfigurer
(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors) Return aRuntimeWiringConfigurer
that installs aWiringFactory
to find queries with a return type whose name matches to the domain type name of the given repositories and registersDataFetcher
s for them.static GraphQLTypeVisitor
autoRegistrationTypeVisitor
(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors) Deprecated.static <T> QuerydslDataFetcher.Builder<T,
T> builder
(org.springframework.data.querydsl.QuerydslPredicateExecutor<T> executor) Create a newQuerydslDataFetcher.Builder
acceptingQuerydslPredicateExecutor
to build aDataFetcher
.static <T> QuerydslDataFetcher.ReactiveBuilder<T,
T> builder
(org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<T> executor) Create a newQuerydslDataFetcher.ReactiveBuilder
acceptingReactiveQuerydslPredicateExecutor
to build a reactiveDataFetcher
.protected com.querydsl.core.types.Predicate
buildPredicate
(DataFetchingEnvironment environment) Prepare aPredicate
from GraphQL request arguments, also applying anyQuerydslBinderCustomizer
that may have been configured.protected Collection<String>
buildPropertyPaths
(DataFetchingFieldSelectionSet selection, Class<?> resultType) protected boolean
requiresProjection
(Class<?> resultType)
-
Method Details
-
buildPredicate
Prepare aPredicate
from GraphQL request arguments, also applying anyQuerydslBinderCustomizer
that may have been configured.- Parameters:
environment
- contextual info for the GraphQL request- Returns:
- the resulting predicate
-
requiresProjection
-
buildPropertyPaths
protected Collection<String> buildPropertyPaths(DataFetchingFieldSelectionSet selection, Class<?> resultType) -
builder
public static <T> QuerydslDataFetcher.Builder<T,T> builder(org.springframework.data.querydsl.QuerydslPredicateExecutor<T> executor) Create a newQuerydslDataFetcher.Builder
acceptingQuerydslPredicateExecutor
to build aDataFetcher
.- Type Parameters:
T
- result type- Parameters:
executor
- the repository object to use- Returns:
- a new builder
-
builder
public static <T> QuerydslDataFetcher.ReactiveBuilder<T,T> builder(org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<T> executor) Create a newQuerydslDataFetcher.ReactiveBuilder
acceptingReactiveQuerydslPredicateExecutor
to build a reactiveDataFetcher
.- Type Parameters:
T
- result type- Parameters:
executor
- the repository object to use- Returns:
- a new builder
-
autoRegistrationConfigurer
public static RuntimeWiringConfigurer autoRegistrationConfigurer(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors) Return aRuntimeWiringConfigurer
that installs aWiringFactory
to find queries with a return type whose name matches to the domain type name of the given repositories and registersDataFetcher
s for them.Note: This applies only to top-level queries and repositories annotated with
@GraphQlRepository
. If a repository is also an instance ofQuerydslBinderCustomizer
, this is transparently detected and applied through theQuerydslDataFetcher
builder methods.- Parameters:
executors
- repositories to consider for registrationreactiveExecutors
- reactive repositories to consider for registration- Returns:
- the created configurer
-
autoRegistrationTypeVisitor
@Deprecated public static GraphQLTypeVisitor autoRegistrationTypeVisitor(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors) Deprecated.in favor ofautoRegistrationConfigurer(List, List)
Return aGraphQLTypeVisitor
that auto-registers the given Querydsl repositories for queries that do not already have a registeredDataFetcher
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 ofQuerydslBinderCustomizer
, this is transparently detected and applied through theQuerydslDataFetcher
builder methods.- Parameters:
executors
- repositories to consider for registrationreactiveExecutors
- reactive repositories to consider for registration- Returns:
- the created visitor
-
autoRegistrationConfigurer(List, List)