From 08d49a848e2cbf59ecd12d55ad474ace3ce81952 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 6 Jul 2021 08:49:35 +0200 Subject: [PATCH] Refine Querydsl integration documentation Update repository example to implement Repository. Mention customizing and projection capabilities. See gh-78 --- spring-graphql-docs/src/docs/asciidoc/index.adoc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spring-graphql-docs/src/docs/asciidoc/index.adoc b/spring-graphql-docs/src/docs/asciidoc/index.adoc index fce3bdff..83f9ccf1 100644 --- a/spring-graphql-docs/src/docs/asciidoc/index.adoc +++ b/spring-graphql-docs/src/docs/asciidoc/index.adoc @@ -300,12 +300,15 @@ default it is marked as `INTERNAL_ERROR`. Spring GraphQL supports use of http://www.querydsl.com/[Querydsl] to fetch data through the Spring Data https://docs.spring.io/spring-data/commons/docs/current/reference/html/#core.extensions[Querydsl extension]. +Querydsl provides a flexible yet typesafe approach to express query predicates by +generating a meta-model using annotation processors. For example, declare a repository as `QuerydslPredicateExecutor`: [source,java,indent=0,subs="verbatim,quotes"] ---- -public interface AccountRepository extends QuerydslPredicateExecutor { +public interface AccountRepository extends Repository, + QuerydslPredicateExecutor { } ---- @@ -330,6 +333,14 @@ If the repository is `ReactiveQuerydslPredicateExecutor`, the builder returns `DataFetcher>` or `DataFetcher>`. Spring Data supports this variant for MongoDB. +The Querydsl integration allows customizing the request parameters binding onto a +`Predicate` by accepting a `QuerydslBinderCustomizer`. Request parameters are bound +by default as "is equal to" for each available property in the request. + +`QuerydslDataFetcher` supports +https://docs.spring.io/spring-data/commons/docs/current/reference/html/#projections[interface and DTO projections] +to transform query results before returning these for further GraphQL processing. + The {repository}/samples/webmvc-http[webmvc-http] sample in the Spring GraphQL repository uses Querydsl to fetch `artifactRepositories`.