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 DataFetcher
s.
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
, thenScrollSubrangeMethodArgumentResolver
is configured for use. If not, thenSubrangeMethodArgumentResolver
is added instead.SortStrategy
-- if present, thenSortMethodArgumentResolver
is configured for use.
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev, Brian Clozel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add aHandlerMethodArgumentResolver
for custom controller method arguments.void
addFormatterRegistrar
(FormatterRegistrar registrar) Add aFormatterRegistrar
to customize theConversionService
that assists in binding GraphQL arguments onto@Argument
annotated method parameters.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.Return aDataFetcherExceptionResolver
that resolves exceptions with@GraphQlExceptionHandler
methods in@ControllerAdvice
classes declared in Spring configuration.protected final ApplicationContext
void
setApplicationContext
(ApplicationContext applicationContext) void
setDataBinderInitializer
(Consumer<DataBinder> consumer) Deprecated, for removal: This API element is subject to removal in a future version.void
setExecutor
(Executor executor) 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
-
addFormatterRegistrar
Add aFormatterRegistrar
to customize theConversionService
that assists in binding GraphQL arguments onto@Argument
annotated method parameters. -
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
-
getExceptionResolver
Return aDataFetcherExceptionResolver
that resolves exceptions with@GraphQlExceptionHandler
methods in@ControllerAdvice
classes declared in Spring configuration. This is useful primarily for exceptions from non-controllerDataFetcher
s since exceptions from@SchemaMapping
controller methods are handled automatically at the point of invocation.- Returns:
- a resolver instance that can be plugged into
GraphQlSource.Builder
- Since:
- 1.2
-
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
-
setExecutor
Configure anExecutor
to use for asynchronous handling ofCallable
return values from controller methods.By default, this is not set in which case controller methods with a
Callable
return value cannot be registered.- Parameters:
executor
- the executor to use
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-
obtainApplicationContext
-
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
-
configure
Alternative toconfigure(RuntimeWiring.Builder)
that registers data fetchers in aGraphQLCodeRegistry.Builder
. This could be used with programmatic creation ofGraphQLSchema
.
-
DataBinder
is no longer used to bind arguments