T
- returned result typepublic abstract class QueryByExampleDataFetcher<T> extends 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 RuntimeWiringConfigurer
that can auto-register repositories
annotated with @GraphQlRepository
.
GraphQlRepository
,
QueryByExampleExecutor
,
ReactiveQueryByExampleExecutor
,
Example
,
Spring Data Query By Example extensionModifier 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 RuntimeWiringConfigurer |
autoRegistrationConfigurer(List<org.springframework.data.repository.query.QueryByExampleExecutor<?>> executors,
List<org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<?>> reactiveExecutors)
Return a
RuntimeWiringConfigurer that installs a
WiringFactory to find queries with a return
type whose name matches to the domain type name of the given repositories
and registers DataFetcher s for them. |
static GraphQLTypeVisitor |
autoRegistrationTypeVisitor(List<org.springframework.data.repository.query.QueryByExampleExecutor<?>> executors,
List<org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<?>> reactiveExecutors)
Deprecated.
in favor of
autoRegistrationConfigurer(List, List) |
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(DataFetchingEnvironment env)
Prepare an
Example from GraphQL request arguments. |
protected Collection<String> |
buildPropertyPaths(DataFetchingFieldSelectionSet selection,
Class<?> resultType) |
protected boolean |
requiresProjection(Class<?> resultType) |
protected org.springframework.data.domain.Example<T> buildExample(DataFetchingEnvironment env) throws BindException
Example
from GraphQL request arguments.env
- contextual info for the GraphQL requestBindException
protected boolean requiresProjection(Class<?> resultType)
protected Collection<String> buildPropertyPaths(DataFetchingFieldSelectionSet selection, 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 RuntimeWiringConfigurer autoRegistrationConfigurer(List<org.springframework.data.repository.query.QueryByExampleExecutor<?>> executors, List<org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<?>> reactiveExecutors)
RuntimeWiringConfigurer
that installs a
WiringFactory
to find queries with a return
type whose name matches to the domain type name of the given repositories
and registers DataFetcher
s for them.
Note: This applies only to top-level queries and
repositories annotated with @GraphQlRepository
.
executors
- repositories to consider for registrationreactiveExecutors
- reactive repositories to consider for registration@Deprecated public static GraphQLTypeVisitor autoRegistrationTypeVisitor(List<org.springframework.data.repository.query.QueryByExampleExecutor<?>> executors, List<org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<?>> reactiveExecutors)
autoRegistrationConfigurer(List, List)
GraphQLTypeVisitor
that finds queries with a return type
whose name matches to the domain type name of the given repositories and
registers DataFetcher
s 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