Class QuerydslDataFetcher<T>
java.lang.Object
org.springframework.graphql.data.query.QuerydslDataFetcher<T>
- Type Parameters:
T
- returned result type
Main class to create a
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) Variation ofautoRegistrationConfigurer(List, List, CursorStrategy, ScrollSubrange)
without aCursorStrategy
and defaultScrollSubrange
.static RuntimeWiringConfigurer
autoRegistrationConfigurer
(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors, CursorStrategy<org.springframework.data.domain.ScrollPosition> cursorStrategy, ScrollSubrange defaultScrollSubrange) 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 <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) Provides shared implementation ofSelfDescribingDataFetcher.getDescription()
for all subclasses.protected boolean
requiresProjection
(Class<?> resultType) toString()
-
Method Details
-
getDescription
Provides shared implementation ofSelfDescribingDataFetcher.getDescription()
for all subclasses.- Since:
- 1.2.0
-
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) -
toString
-
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) Variation ofautoRegistrationConfigurer(List, List, CursorStrategy, ScrollSubrange)
without aCursorStrategy
and defaultScrollSubrange
. For default values, see the respective methods onQuerydslDataFetcher.Builder
andQuerydslDataFetcher.ReactiveBuilder
.- Parameters:
executors
- repositories to consider for registrationreactiveExecutors
- reactive repositories to consider for registration
-
autoRegistrationConfigurer
public static RuntimeWiringConfigurer autoRegistrationConfigurer(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors, @Nullable CursorStrategy<org.springframework.data.domain.ScrollPosition> cursorStrategy, @Nullable ScrollSubrange defaultScrollSubrange) 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 registrationcursorStrategy
- for decoding cursors in pagination requests; ifnull
, thenQuerydslDataFetcher.Builder.cursorStrategy
defaults apply.defaultScrollSubrange
- default parameters for scrolling; ifnull
, thenQuerydslDataFetcher.Builder.defaultScrollSubrange(int, java.util.function.Function<java.lang.Boolean, org.springframework.data.domain.ScrollPosition>)
defaults apply.- Returns:
- the created configurer
- Since:
- 1.2.0
-