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 DataFetcher
s.
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
, thenScrollSubrangeMethodArgumentResolver
is configured for use. If not, thenSubrangeMethodArgumentResolver
is added instead.SortStrategy
-- if present, thenSortMethodArgumentResolver
is 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 TypeMethodDescriptionvoid
Add aHandlerMethodArgumentResolver
for custom controller method arguments.void
void
configure
(GraphQLCodeRegistry.Builder codeRegistryBuilder) Alternative toconfigure(RuntimeWiring.Builder)
that registers data fetchers in aGraphQLCodeRegistry.Builder
.void
configure
(RuntimeWiring.Builder runtimeWiringBuilder) Apply changes to theRuntimeWiring.Builder
such as registeringDataFetcher
s, custom scalar types, and more.protected static String
formatRegistrations
(RuntimeWiring.Builder wiringBuilder) protected HandlerMethod
getHandlerMethod
(DataFetcherMappingInfo mappingInfo) protected DataFetcherMappingInfo
getMappingInfo
(Method method, Object handler, Class<?> handlerType) protected HandlerMethodArgumentResolverComposite
void
setDataBinderInitializer
(Consumer<DataBinder> consumer) Deprecated, for removal: This API element is subject to removal in a future version.void
Provides 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, shouldInvokeAsync
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.graphql.execution.RuntimeWiringConfigurer
configure
-
Constructor Details
-
AnnotatedControllerConfigurer
public AnnotatedControllerConfigurer()
-
-
Method Details
-
addCustomArgumentResolver
Add aHandlerMethodArgumentResolver
for 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:RuntimeWiringConfigurer
Provides the configurer access to theTypeDefinitionRegistry
.- Specified by:
setTypeDefinitionRegistry
in 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 aDataBinder
is no longer used to bind argumentsConfigure an initializer that configures theDataBinder
before the binding process.- Parameters:
consumer
- the data binder initializer- Since:
- 1.0.1
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Overrides:
afterPropertiesSet
in classAnnotatedControllerDetectionSupport<DataFetcherMappingInfo>
-
initArgumentResolvers
- Specified by:
initArgumentResolvers
in classAnnotatedControllerDetectionSupport<DataFetcherMappingInfo>
-
configure
Description copied from interface:RuntimeWiringConfigurer
Apply changes to theRuntimeWiring.Builder
such as registeringDataFetcher
s, custom scalar types, and more.- Specified by:
configure
in interfaceRuntimeWiringConfigurer
- Parameters:
runtimeWiringBuilder
- the builder to configure
-
getMappingInfo
protected DataFetcherMappingInfo getMappingInfo(Method method, Object handler, Class<?> handlerType) - Specified by:
getMappingInfo
in classAnnotatedControllerDetectionSupport<DataFetcherMappingInfo>
-
getHandlerMethod
- Specified by:
getHandlerMethod
in 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
-
DataBinder
is no longer used to bind arguments