T - returned result typepublic abstract class QueryByExampleDataFetcher<T>
extends java.lang.Object
DataFetcher from a Query By Example repository.
To create an instance, use one of the following:
For example:
interface BookRepository extends
Repository<Book, String>, QueryByExampleExecutor<Book>{}
TypeRuntimeWiring wiring = … ;
BookRepository repository = … ;
DataFetcher<?> forMany =
wiring.dataFetcher("books", QueryByExampleDataFetcher.builder(repository).many());
DataFetcher<?> forSingle =
wiring.dataFetcher("book", QueryByExampleDataFetcher.builder(repository).single());
See methods on QueryByExampleDataFetcher.Builder and
QueryByExampleDataFetcher.ReactiveBuilder for further options on
result projections and sorting.
QueryByExampleDataFetcher exposes
a GraphQLTypeVisitor that can auto-register repositories annotated with
@GraphQlRepository.
GraphQlRepository,
QueryByExampleExecutor,
ReactiveQueryByExampleExecutor,
Example,
Spring Data Query By Example extension| Modifier and Type | Class and Description |
|---|---|
static class |
QueryByExampleDataFetcher.Builder<T,R>
Builder for a Query by Example-based
DataFetcher. |
static class |
QueryByExampleDataFetcher.ReactiveBuilder<T,R>
Builder for a reactive Query by Example-based
DataFetcher. |
| Modifier and Type | Method and Description |
|---|---|
static graphql.schema.GraphQLTypeVisitor |
autoRegistrationTypeVisitor(java.util.List<org.springframework.data.repository.query.QueryByExampleExecutor<?>> executors,
java.util.List<org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<?>> reactiveExecutors)
Create a
GraphQLTypeVisitor that finds queries with a return type
whose name matches to the domain type name of the given repositories and
registers DataFetchers for those queries. |
static <T> QueryByExampleDataFetcher.Builder<T,T> |
builder(org.springframework.data.repository.query.QueryByExampleExecutor<T> executor)
Create a new
QueryByExampleDataFetcher.Builder accepting QueryByExampleExecutor
to build a DataFetcher. |
static <T> QueryByExampleDataFetcher.ReactiveBuilder<T,T> |
builder(org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<T> executor)
Create a new
QueryByExampleDataFetcher.ReactiveBuilder accepting
ReactiveQueryByExampleExecutor to build a DataFetcher. |
protected org.springframework.data.domain.Example<T> |
buildExample(graphql.schema.DataFetchingEnvironment env)
Prepare an
Example from GraphQL query arguments. |
protected java.util.Collection<java.lang.String> |
buildPropertyPaths(graphql.schema.DataFetchingFieldSelectionSet selection,
java.lang.Class<?> resultType) |
protected boolean |
requiresProjection(java.lang.Class<?> resultType) |
protected org.springframework.data.domain.Example<T> buildExample(graphql.schema.DataFetchingEnvironment env)
Example from GraphQL query arguments.env - contextual info for the GraphQL queryprotected boolean requiresProjection(java.lang.Class<?> resultType)
protected java.util.Collection<java.lang.String> buildPropertyPaths(graphql.schema.DataFetchingFieldSelectionSet selection,
java.lang.Class<?> resultType)
public static <T> QueryByExampleDataFetcher.Builder<T,T> builder(org.springframework.data.repository.query.QueryByExampleExecutor<T> executor)
QueryByExampleDataFetcher.Builder accepting QueryByExampleExecutor
to build a DataFetcher.T - the domain type of the repositoryexecutor - the QBE repository object to usepublic static <T> QueryByExampleDataFetcher.ReactiveBuilder<T,T> builder(org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<T> executor)
QueryByExampleDataFetcher.ReactiveBuilder accepting
ReactiveQueryByExampleExecutor to build a DataFetcher.T - the domain type of the repositoryexecutor - the QBE repository object to usepublic static graphql.schema.GraphQLTypeVisitor autoRegistrationTypeVisitor(java.util.List<org.springframework.data.repository.query.QueryByExampleExecutor<?>> executors,
java.util.List<org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<?>> reactiveExecutors)
GraphQLTypeVisitor that finds queries with a return type
whose name matches to the domain type name of the given repositories and
registers DataFetchers for those queries.
Note: currently, this method will match only to queries under the top-level "Query" type in the GraphQL schema.
executors - repositories to consider for registrationreactiveExecutors - reactive repositories to consider for registration