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:
-
GraphQlRepositoryQuerydslPredicateExecutorReactiveQuerydslPredicateExecutorPredicateQuerydslBinderCustomizer- Spring Data Querydsl extension
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for a Querydsl-basedDataFetcher.static interfaceCallback interface that can be used to customize QuerydslDataFetcherQuerydslDataFetcher.Builderto change its configuration.static classBuilder for a reactive Querydsl-basedDataFetcher.static interfaceCallback interface that can be used to customize QuerydslDataFetcherQuerydslDataFetcher.ReactiveBuilderto change its configuration. -
Method Summary
Modifier and TypeMethodDescriptionstatic RuntimeWiringConfigurerautoRegistrationConfigurer(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors) Variation ofautoRegistrationConfigurer(List, List, CursorStrategy, ScrollSubrange)without aCursorStrategyand defaultScrollSubrange.static RuntimeWiringConfigurerautoRegistrationConfigurer(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors, CursorStrategy<org.springframework.data.domain.ScrollPosition> cursorStrategy, ScrollSubrange defaultScrollSubrange) Return aRuntimeWiringConfigurerthat installs aWiringFactoryto find queries with a return type whose name matches to the domain type name of the given repositories and registersDataFetchers for them.static GraphQLTypeVisitorautoRegistrationTypeVisitor(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors) Deprecated, for removal: This API element is subject to removal in a future version.static <T> QuerydslDataFetcher.Builder<T,T> builder(org.springframework.data.querydsl.QuerydslPredicateExecutor<T> executor) Create a newQuerydslDataFetcher.BuilderacceptingQuerydslPredicateExecutorto build aDataFetcher.static <T> QuerydslDataFetcher.ReactiveBuilder<T,T> builder(org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<T> executor) Create a newQuerydslDataFetcher.ReactiveBuilderacceptingReactiveQuerydslPredicateExecutorto build a reactiveDataFetcher.protected com.querydsl.core.types.PredicatebuildPredicate(DataFetchingEnvironment environment) Prepare aPredicatefrom GraphQL request arguments, also applying anyQuerydslBinderCustomizerthat may have been configured.protected Collection<String>buildPropertyPaths(DataFetchingFieldSelectionSet selection, Class<?> resultType) Provides shared implementation ofSelfDescribingDataFetcher.getDescription()for all subclasses.protected booleanrequiresProjection(Class<?> resultType) toString()
-
Method Details
-
getDescription
Provides shared implementation ofSelfDescribingDataFetcher.getDescription()for all subclasses.- Since:
- 1.2.0
-
buildPredicate
Prepare aPredicatefrom GraphQL request arguments, also applying anyQuerydslBinderCustomizerthat 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.BuilderacceptingQuerydslPredicateExecutorto 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.ReactiveBuilderacceptingReactiveQuerydslPredicateExecutorto 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 aCursorStrategyand defaultScrollSubrange. For default values, see the respective methods onQuerydslDataFetcher.BuilderandQuerydslDataFetcher.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 aRuntimeWiringConfigurerthat installs aWiringFactoryto find queries with a return type whose name matches to the domain type name of the given repositories and registersDataFetchers 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 theQuerydslDataFetcherbuilder methods.- Parameters:
executors- repositories to consider for registrationreactiveExecutors- reactive repositories to consider for registrationcursorStrategy- for decoding cursors in pagination requests; ifnull, thenQuerydslDataFetcher.Builder.cursorStrategydefaults 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
-
autoRegistrationTypeVisitor
@Deprecated(since="1.0.0", forRemoval=true) public static GraphQLTypeVisitor autoRegistrationTypeVisitor(List<org.springframework.data.querydsl.QuerydslPredicateExecutor<?>> executors, List<org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors) Deprecated, for removal: This API element is subject to removal in a future version.since 1.0.0 in favor ofautoRegistrationConfigurer(List, List)Return aGraphQLTypeVisitorthat auto-registers the given Querydsl repositories for queries that do not already have a registeredDataFetcherand 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 theQuerydslDataFetcherbuilder methods.- Parameters:
executors- repositories to consider for registrationreactiveExecutors- reactive repositories to consider for registration- Returns:
- the created visitor
-
autoRegistrationConfigurer(List, List)