Class AnnotatedControllerConfigurer
java.lang.Object
org.springframework.graphql.data.method.annotation.support.AnnotatedControllerConfigurer
- All Implemented Interfaces:
Aware,InitializingBean,ApplicationContextAware,RuntimeWiringConfigurer
public class AnnotatedControllerConfigurer
extends Object
implements ApplicationContextAware, InitializingBean, RuntimeWiringConfigurer
RuntimeWiringConfigurer that finds @SchemaMapping
annotated handler methods in @Controller classes declared in
Spring configuration, and registers them as DataFetchers.
In addition to initializing a RuntimeWiring.Builder, this class, also
provides an option to configure
data fetchers on a GraphQLCodeRegistry.Builder.
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.
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev, Brian Clozel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd aHandlerMethodArgumentResolverfor custom controller method arguments.voidaddFormatterRegistrar(FormatterRegistrar registrar) Add aFormatterRegistrarto customize theConversionServicethat assists in binding GraphQL arguments onto@Argumentannotated method parameters.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.Return aDataFetcherExceptionResolverthat resolves exceptions with@GraphQlExceptionHandlermethods in@ControllerAdviceclasses declared in Spring configuration.protected final ApplicationContextvoidsetApplicationContext(ApplicationContext applicationContext) voidsetDataBinderInitializer(Consumer<DataBinder> consumer) Deprecated, for removal: This API element is subject to removal in a future version.voidsetExecutor(Executor executor) voidsetFallBackOnDirectFieldAccess(boolean fallBackOnDirectFieldAccess) Whether binding GraphQL arguments onto@Argumentshould falls back to direct field access in case the target object does not use accessor methods.Methods 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
-
addFormatterRegistrar
Add aFormatterRegistrarto customize theConversionServicethat assists in binding GraphQL arguments onto@Argumentannotated method parameters. -
setFallBackOnDirectFieldAccess
public void setFallBackOnDirectFieldAccess(boolean fallBackOnDirectFieldAccess) Whether binding GraphQL arguments onto@Argumentshould falls back to direct field access in case the target object does not use accessor methods.- Since:
- 1.2.0
-
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
-
getExceptionResolver
Return aDataFetcherExceptionResolverthat resolves exceptions with@GraphQlExceptionHandlermethods in@ControllerAdviceclasses declared in Spring configuration. This is useful primarily for exceptions from non-controllerDataFetchers since exceptions from@SchemaMappingcontroller methods are handled automatically at the point of invocation.- Returns:
- a resolver instance that can be plugged into
GraphQlSource.Builder - Since:
- 1.2.0
-
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
-
setExecutor
Configure anExecutorto use for asynchronous handling ofCallablereturn values from controller methods.By default, this is not set in which case controller methods with a
Callablereturn value cannot be registered.- Parameters:
executor- the executor to use
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
obtainApplicationContext
-
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
-
configure
Alternative toconfigure(RuntimeWiring.Builder)that registers data fetchers in aGraphQLCodeRegistry.Builder. This could be used with programmatic creation ofGraphQLSchema.
-
DataBinderis no longer used to bind arguments