Class ArgumentMethodArgumentResolver
java.lang.Object
org.springframework.graphql.data.method.annotation.support.ArgumentMethodArgumentResolver
- All Implemented Interfaces:
HandlerMethodArgumentResolver
Resolver for a method parameter that is annotated with
@Argument. The specified raw argument value is obtained via
DataFetchingEnvironment.getArgument(String) and bound to a higher
level object via GraphQlArgumentBinder to match the target method
parameter type.
This resolver also supports wrapping the target object with
ArgumentValue if the application wants to differentiate between an
input argument that was set to null vs not provided at all. When
this wrapper type is used, the annotation is optional, and the name of the
argument is derived from the method parameter name.
An ArgumentValue can also be nested within the object structure
of an @Argument-annotated method parameter.
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev, Brian Clozel
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectdoBind(DataFetchingEnvironment environment, String name, ResolvableType targetType) Perform the binding with the configuredbinder.Return the configuredGraphQlArgumentBinder.resolveArgument(MethodParameter parameter, DataFetchingEnvironment environment) Resolve a method parameter to a value.booleansupportsParameter(MethodParameter parameter) Whether this resolver supports the givenMethodParameter.
-
Constructor Details
-
ArgumentMethodArgumentResolver
-
-
Method Details
-
getArgumentBinder
Return the configuredGraphQlArgumentBinder.- Since:
- 1.3.0
-
supportsParameter
Description copied from interface:HandlerMethodArgumentResolverWhether this resolver supports the givenMethodParameter.- Specified by:
supportsParameterin interfaceHandlerMethodArgumentResolver- Parameters:
parameter- the method parameter to check for support
-
resolveArgument
public Object resolveArgument(MethodParameter parameter, DataFetchingEnvironment environment) throws Exception Description copied from interface:HandlerMethodArgumentResolverResolve a method parameter to a value.- Specified by:
resolveArgumentin interfaceHandlerMethodArgumentResolver- Parameters:
parameter- the method parameter to resolve. This parameter must have previously checked viaHandlerMethodArgumentResolver.supportsParameter(org.springframework.core.MethodParameter).environment- the environment to use to resolve the value- Returns:
- the resolved value, which may be
nullif not resolved; the value may also be aMonoif it requires asynchronous resolution. - Throws:
Exception- in case of errors with the preparation of argument values
-
doBind
@Nullable protected Object doBind(DataFetchingEnvironment environment, String name, ResolvableType targetType) throws BindException Perform the binding with the configuredbinder.- Parameters:
environment- for access to the argumentsname- the name of an argument, ornullto use the full maptargetType- the type of Object to create- Throws:
BindException- Since:
- 1.3.0
-