public class ProjectedPayloadMethodArgumentResolver extends Object implements HandlerMethodArgumentResolver
@ProjectedPayload,
either based on the complete DataFetchingEnvironment.getArguments()
map, or based on a specific argument within the map when the method
parameter is annotated with @Argument.
Projected payloads consist of the projection interface and accessor
methods. Projections can be closed or open projections. Closed projections
use interface getter methods to access underlying properties directly.
Open projection methods make use of the @Value annotation to
evaluate SpEL expressions against the underlying target object.
For example:
@ProjectedPayload
interface BookProjection {
String getName();
}
@ProjectedPayload
interface BookProjection {
@Value("#{target.author + ' ' + target.name}")
String getAuthorAndName();
}
| Constructor and Description |
|---|
ProjectedPayloadMethodArgumentResolver(ApplicationContext applicationContext)
Create a new
ProjectedPayloadMethodArgumentResolver using the given context. |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
project(Class<?> projectionType,
Object projectionSource) |
Object |
resolveArgument(MethodParameter parameter,
DataFetchingEnvironment environment)
Resolve a method parameter to a value.
|
boolean |
supportsParameter(MethodParameter parameter)
Whether this resolver supports the given
MethodParameter. |
public ProjectedPayloadMethodArgumentResolver(ApplicationContext applicationContext)
ProjectedPayloadMethodArgumentResolver using the given context.applicationContext - the ApplicationContext to use for bean lookup and class loadingpublic boolean supportsParameter(MethodParameter parameter)
HandlerMethodArgumentResolverMethodParameter.supportsParameter in interface HandlerMethodArgumentResolverpublic Object resolveArgument(MethodParameter parameter, DataFetchingEnvironment environment) throws Exception
HandlerMethodArgumentResolverresolveArgument in interface HandlerMethodArgumentResolverparameter - the method parameter to resolve. This parameter must
have previously checked via HandlerMethodArgumentResolver.supportsParameter(org.springframework.core.MethodParameter).environment - the environment to use to resolve the valuenull if not resolved;
the value may also be a Mono if it
requires asynchronous resolution.Exception - in case of errors with the preparation of argument values