Class AnnotatedControllerConfigurer
java.lang.Object
org.springframework.graphql.data.method.annotation.support.AnnotatedControllerDetectionSupport<DataFetcherMappingInfo>
org.springframework.graphql.data.method.annotation.support.AnnotatedControllerConfigurer
- All Implemented Interfaces:
Aware,InitializingBean,ApplicationContextAware,RuntimeWiringConfigurer
public class AnnotatedControllerConfigurer
extends AnnotatedControllerDetectionSupport<DataFetcherMappingInfo>
implements RuntimeWiringConfigurer
RuntimeWiringConfigurer that finds @SchemaMapping
and @BatchMapping methods in @Controller
classes, and registers them as DataFetchers.
This class detects the following strategies in Spring configuration, expecting to find a single, unique bean of that type:
CursorStrategy-- if Spring Data is present, and the strategy supportsScrollPosition, thenScrollSubrangeMethodArgumentResolveris configured for use. If not, thenSubrangeMethodArgumentResolveris added instead.SortStrategy-- if present, thenSortMethodArgumentResolveris configured for use.
In addition to initializing a RuntimeWiring.Builder, this class, also
provides an option to configure
data fetchers on a GraphQLCodeRegistry.Builder.
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev, Brian Clozel
-
Field Summary
Fields inherited from class org.springframework.graphql.data.method.annotation.support.AnnotatedControllerDetectionSupport
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd aHandlerMethodArgumentResolverfor custom controller method arguments.voidvoidconfigure(GraphQLCodeRegistry.Builder codeRegistryBuilder) Alternative toconfigure(RuntimeWiring.Builder)that registers data fetchers in aGraphQLCodeRegistry.Builder.voidconfigure(RuntimeWiring.Builder runtimeWiringBuilder) Apply changes to theRuntimeWiring.Buildersuch as registeringDataFetchers, custom scalar types, and more.protected static StringformatRegistrations(RuntimeWiring.Builder wiringBuilder) protected HandlerMethodgetHandlerMethod(DataFetcherMappingInfo mappingInfo) protected DataFetcherMappingInfogetMappingInfo(Method method, Object handler, Class<?> handlerType) protected HandlerMethodArgumentResolverCompositevoidsetDataBinderInitializer(Consumer<DataBinder> consumer) Deprecated, for removal: This API element is subject to removal in a future version.voidProvides the configurer access to theTypeDefinitionRegistry.Methods inherited from class org.springframework.graphql.data.method.annotation.support.AnnotatedControllerDetectionSupport
addFormatterRegistrar, createHandlerMethod, detectHandlerMethods, getApplicationContext, getArgumentResolvers, getConversionService, getExceptionResolver, getExecutor, isFallBackOnDirectFieldAccess, obtainApplicationContext, setApplicationContext, setBlockingMethodPredicate, setExecutor, setFallBackOnDirectFieldAccess, shouldInvokeAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.graphql.execution.RuntimeWiringConfigurer
configure
-
Constructor Details
-
AnnotatedControllerConfigurer
public AnnotatedControllerConfigurer()
-
-
Method Details
-
addCustomArgumentResolver
Add aHandlerMethodArgumentResolverfor custom controller method arguments. Such custom resolvers are ordered after built-in resolvers except forSourceMethodArgumentResolver, which is always last.- Parameters:
resolver- the resolver to add.- Since:
- 1.2.0
-
setTypeDefinitionRegistry
Description copied from interface:RuntimeWiringConfigurerProvides the configurer access to theTypeDefinitionRegistry.- Specified by:
setTypeDefinitionRegistryin interfaceRuntimeWiringConfigurer- Parameters:
registry- the registry
-
setDataBinderInitializer
@Deprecated(since="1.1.0", forRemoval=true) public void setDataBinderInitializer(@Nullable Consumer<DataBinder> consumer) Deprecated, for removal: This API element is subject to removal in a future version.this property is deprecated, ignored, and should not be necessary as aDataBinderis no longer used to bind argumentsConfigure an initializer that configures theDataBinderbefore the binding process.- Parameters:
consumer- the data binder initializer- Since:
- 1.0.1
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean- Overrides:
afterPropertiesSetin classAnnotatedControllerDetectionSupport<DataFetcherMappingInfo>
-
initArgumentResolvers
- Specified by:
initArgumentResolversin classAnnotatedControllerDetectionSupport<DataFetcherMappingInfo>
-
configure
Description copied from interface:RuntimeWiringConfigurerApply changes to theRuntimeWiring.Buildersuch as registeringDataFetchers, custom scalar types, and more.- Specified by:
configurein interfaceRuntimeWiringConfigurer- Parameters:
runtimeWiringBuilder- the builder to configure
-
getMappingInfo
protected DataFetcherMappingInfo getMappingInfo(Method method, Object handler, Class<?> handlerType) - Specified by:
getMappingInfoin classAnnotatedControllerDetectionSupport<DataFetcherMappingInfo>
-
getHandlerMethod
- Specified by:
getHandlerMethodin classAnnotatedControllerDetectionSupport<DataFetcherMappingInfo>
-
formatRegistrations
-
configure
Alternative toconfigure(RuntimeWiring.Builder)that registers data fetchers in aGraphQLCodeRegistry.Builder. This could be used with programmatic creation ofGraphQLSchema.- Parameters:
codeRegistryBuilder- the code registry
-
DataBinderis no longer used to bind arguments