diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/GraphQlArgumentBinder.java b/spring-graphql/src/main/java/org/springframework/graphql/data/GraphQlArgumentBinder.java index 7237a361..2c5fd9c5 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/GraphQlArgumentBinder.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/GraphQlArgumentBinder.java @@ -48,11 +48,11 @@ import org.springframework.validation.FieldError; /** - * Bind a GraphQL argument values to higher level objects. + * Bind a GraphQL argument, or the full arguments map, onto a target object. * *

Binding is performed by mapping argument values to a primary data - * constructor of the target Object, or by using a default constructor - * and mapping argument values to properties. This is applied recursively. + * constructor of the target object, or by using a default constructor and + * mapping argument values to its properties. This is applied recursively. * * @author Brian Clozel * @author Rossen Stoyanchev @@ -93,9 +93,9 @@ public class GraphQlArgumentBinder { /** - * Bind a single argument or the full arguments map onto an object of the + * Bind a single argument, or the full arguments map, onto an object of the * given target type. - * @param environment to obtain the argument value(s) from + * @param environment for access to the arguments * @param argumentName the name of the argument to bind, or {@code null} to * use the full arguments map * @param targetType the type of Object to create @@ -103,8 +103,8 @@ public class GraphQlArgumentBinder { * @throws BindException in case of binding issues such as conversion errors, * mismatches between the source and the target object structure, and so on. * Binding issues are accumulated as {@link BindException#getFieldErrors() - * field errors} where the {@code field} of each error is the argument path - * where the issue occurred. + * field errors} where the {@link FieldError#getField() field} of each error + * is the argument path where the issue occurred. */ @Nullable @SuppressWarnings("unchecked") diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerConfigurer.java b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerConfigurer.java index bc4cd732..b0d526cb 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerConfigurer.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerConfigurer.java @@ -159,9 +159,9 @@ public class AnnotatedControllerConfigurer this.argumentResolvers.addResolver(new ProjectedPayloadMethodArgumentResolver(obtainApplicationContext())); } this.argumentResolvers.addResolver(new ArgumentMapMethodArgumentResolver()); - GraphQlArgumentBinder initializer = new GraphQlArgumentBinder(this.conversionService); - this.argumentResolvers.addResolver(new ArgumentMethodArgumentResolver(initializer)); - this.argumentResolvers.addResolver(new ArgumentsMethodArgumentResolver(initializer)); + GraphQlArgumentBinder argumentBinder = new GraphQlArgumentBinder(this.conversionService); + this.argumentResolvers.addResolver(new ArgumentMethodArgumentResolver(argumentBinder)); + this.argumentResolvers.addResolver(new ArgumentsMethodArgumentResolver(argumentBinder)); this.argumentResolvers.addResolver(new ContextValueMethodArgumentResolver()); // Type based diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/ArgumentMethodArgumentResolver.java b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/ArgumentMethodArgumentResolver.java index c65df5b3..dc554292 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/ArgumentMethodArgumentResolver.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/ArgumentMethodArgumentResolver.java @@ -37,12 +37,12 @@ import org.springframework.util.StringUtils; */ public class ArgumentMethodArgumentResolver implements HandlerMethodArgumentResolver { - private final GraphQlArgumentBinder argumentInitializer; + private final GraphQlArgumentBinder argumentBinder; - public ArgumentMethodArgumentResolver(GraphQlArgumentBinder initializer) { - Assert.notNull(initializer, "GraphQlArgumentInitializer is required"); - this.argumentInitializer = initializer; + public ArgumentMethodArgumentResolver(GraphQlArgumentBinder argumentBinder) { + Assert.notNull(argumentBinder, "GraphQlArgumentBinder is required"); + this.argumentBinder = argumentBinder; } @@ -55,7 +55,7 @@ public class ArgumentMethodArgumentResolver implements HandlerMethodArgumentReso public Object resolveArgument(MethodParameter parameter, DataFetchingEnvironment environment) throws Exception { String name = getArgumentName(parameter); ResolvableType resolvableType = ResolvableType.forMethodParameter(parameter); - return this.argumentInitializer.bind(environment, name, resolvableType); + return this.argumentBinder.bind(environment, name, resolvableType); } static String getArgumentName(MethodParameter parameter) { diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/ArgumentsMethodArgumentResolver.java b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/ArgumentsMethodArgumentResolver.java index 868f6fa7..c9d794c8 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/ArgumentsMethodArgumentResolver.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/ArgumentsMethodArgumentResolver.java @@ -34,12 +34,12 @@ import org.springframework.util.Assert; */ public class ArgumentsMethodArgumentResolver implements HandlerMethodArgumentResolver { - private final GraphQlArgumentBinder argumentInitializer; + private final GraphQlArgumentBinder argumentBinder; - public ArgumentsMethodArgumentResolver(GraphQlArgumentBinder initializer) { - Assert.notNull(initializer, "GraphQlArgumentInitializer is required"); - this.argumentInitializer = initializer; + public ArgumentsMethodArgumentResolver(GraphQlArgumentBinder argumentBinder) { + Assert.notNull(argumentBinder, "GraphQlArgumentBinder is required"); + this.argumentBinder = argumentBinder; } @@ -51,7 +51,7 @@ public class ArgumentsMethodArgumentResolver implements HandlerMethodArgumentRes @Override public Object resolveArgument(MethodParameter parameter, DataFetchingEnvironment environment) throws Exception { ResolvableType resolvableType = ResolvableType.forMethodParameter(parameter); - return this.argumentInitializer.bind(environment, null, resolvableType); + return this.argumentBinder.bind(environment, null, resolvableType); } } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/query/QueryByExampleDataFetcher.java b/spring-graphql/src/main/java/org/springframework/graphql/data/query/QueryByExampleDataFetcher.java index 00777444..d1d719a2 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/query/QueryByExampleDataFetcher.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/query/QueryByExampleDataFetcher.java @@ -92,12 +92,12 @@ public abstract class QueryByExampleDataFetcher { private final TypeInformation domainType; - private final GraphQlArgumentBinder argumentInitializer; + private final GraphQlArgumentBinder argumentBinder; QueryByExampleDataFetcher(TypeInformation domainType) { this.domainType = domainType; - this.argumentInitializer = new GraphQlArgumentBinder(); + this.argumentBinder = new GraphQlArgumentBinder(); } @@ -109,7 +109,7 @@ public abstract class QueryByExampleDataFetcher { @SuppressWarnings({"ConstantConditions", "unchecked"}) protected Example buildExample(DataFetchingEnvironment env) throws BindException { ResolvableType targetType = ResolvableType.forClass(this.domainType.getType()); - return (Example) Example.of(this.argumentInitializer.bind(env, null, targetType)); + return (Example) Example.of(this.argumentBinder.bind(env, null, targetType)); } protected boolean requiresProjection(Class resultType) { diff --git a/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/GraphQlArgumentBinderTests.java b/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/GraphQlArgumentBinderTests.java index 7fd762b8..00f9cb63 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/GraphQlArgumentBinderTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/GraphQlArgumentBinderTests.java @@ -45,7 +45,8 @@ class GraphQlArgumentBinderTests { private final ObjectMapper mapper = new ObjectMapper(); - private final ThreadLocal initializer = ThreadLocal.withInitial(() -> new GraphQlArgumentBinder(null)); + private final ThreadLocal initializer = + ThreadLocal.withInitial(() -> new GraphQlArgumentBinder(null)); @Test