Class QueryByExampleDataFetcher<T>
java.lang.Object
org.springframework.graphql.data.query.QueryByExampleDataFetcher<T>
- Type Parameters:
- T- returned result type
Main class to create a 
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.
- Since:
- 1.0.0
- Author:
- Greg Turnquist, Rossen Stoyanchev
- See Also:
- 
- GraphQlRepository
- QueryByExampleExecutor
- ReactiveQueryByExampleExecutor
- Example
- Spring Data Query By Example extension
 
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classBuilder for a Query by Example-basedDataFetcher.static interfaceCallback interface that can be used to customize QueryByExampleDataFetcherQueryByExampleDataFetcher.Builderto change its configuration.static classBuilder for a reactive Query by Example-basedDataFetcher.static interfaceCallback interface that can be used to customize QueryByExampleDataFetcherQueryByExampleDataFetcher.ReactiveBuilderto change its configuration.
- 
Method SummaryModifier and TypeMethodDescriptionstatic RuntimeWiringConfigurerautoRegistrationConfigurer(List<org.springframework.data.repository.query.QueryByExampleExecutor<?>> executors, List<org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<?>> reactiveExecutors) Variation ofautoRegistrationConfigurer(List, List, CursorStrategy, ScrollSubrange)without aCursorStrategyand defaultScrollSubrange.static RuntimeWiringConfigurerautoRegistrationConfigurer(List<org.springframework.data.repository.query.QueryByExampleExecutor<?>> executors, List<org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<?>> 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 <T> QueryByExampleDataFetcher.Builder<T,T> builder(org.springframework.data.repository.query.QueryByExampleExecutor<T> executor) Create a newQueryByExampleDataFetcher.BuilderacceptingQueryByExampleExecutorto build aDataFetcher.static <T> QueryByExampleDataFetcher.ReactiveBuilder<T,T> builder(org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<T> executor) Create a newQueryByExampleDataFetcher.ReactiveBuilderacceptingReactiveQueryByExampleExecutorto build aDataFetcher.protected org.springframework.data.domain.Example<T>buildExample(DataFetchingEnvironment environment) Prepare anExamplefrom GraphQL request arguments.protected Collection<String>buildPropertyPaths(DataFetchingFieldSelectionSet selection, Class<?> resultType) Provides shared implementation ofSelfDescribingDataFetcher.getDescription()for all subclasses.protected booleanrequiresProjection(Class<?> resultType) toString()
- 
Method Details- 
getDescriptionProvides shared implementation ofSelfDescribingDataFetcher.getDescription()for all subclasses.- Since:
- 1.2.0
 
- 
buildExampleprotected org.springframework.data.domain.Example<T> buildExample(DataFetchingEnvironment environment) throws BindException Prepare anExamplefrom GraphQL request arguments.- Parameters:
- environment- contextual info for the GraphQL request
- Returns:
- the resulting example
- Throws:
- BindException
 
- 
requiresProjection
- 
buildPropertyPathsprotected Collection<String> buildPropertyPaths(DataFetchingFieldSelectionSet selection, Class<?> resultType) 
- 
toString
- 
builderpublic static <T> QueryByExampleDataFetcher.Builder<T,T> builder(org.springframework.data.repository.query.QueryByExampleExecutor<T> executor) Create a newQueryByExampleDataFetcher.BuilderacceptingQueryByExampleExecutorto build aDataFetcher.- Type Parameters:
- T- the domain type of the repository
- Parameters:
- executor- the QBE repository object to use
- Returns:
- a new builder
 
- 
builderpublic static <T> QueryByExampleDataFetcher.ReactiveBuilder<T,T> builder(org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<T> executor) Create a newQueryByExampleDataFetcher.ReactiveBuilderacceptingReactiveQueryByExampleExecutorto build aDataFetcher.- Type Parameters:
- T- the domain type of the repository
- Parameters:
- executor- the QBE repository object to use
- Returns:
- a new builder
 
- 
autoRegistrationConfigurerpublic static RuntimeWiringConfigurer autoRegistrationConfigurer(List<org.springframework.data.repository.query.QueryByExampleExecutor<?>> executors, List<org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<?>> reactiveExecutors) Variation ofautoRegistrationConfigurer(List, List, CursorStrategy, ScrollSubrange)without aCursorStrategyand defaultScrollSubrange. For default values, see the respective methods onQueryByExampleDataFetcher.BuilderandQueryByExampleDataFetcher.ReactiveBuilder.- Parameters:
- executors- repositories to consider for registration
- reactiveExecutors- reactive repositories to consider for registration
 
- 
autoRegistrationConfigurerpublic static RuntimeWiringConfigurer autoRegistrationConfigurer(List<org.springframework.data.repository.query.QueryByExampleExecutor<?>> executors, List<org.springframework.data.repository.query.ReactiveQueryByExampleExecutor<?>> 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.- Parameters:
- executors- repositories to consider for registration
- reactiveExecutors- reactive repositories to consider for registration
- cursorStrategy- for decoding cursors in pagination requests; if- null, then- QueryByExampleDataFetcher.Builder.cursorStrategydefaults apply.
- defaultScrollSubrange- default parameters for scrolling; if- null, then- QueryByExampleDataFetcher.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
 
 
-