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) 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.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) protected booleanrequiresProjection(Class<?> resultType)
-
Method Details
-
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) -
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) 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 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 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)