@@ -343,11 +343,9 @@ argument values. The values can be simple scalar values (e.g. String, Long), a `
343
343
values for more complex input, or a `List` of values.
344
344
345
345
Use the `@Argument` annotation to have an argument bound to a target object and
346
- injected into the handler method. Binding is performed by mapping argument values to a
347
- primary data constructor of the expected method parameter type, or by using a default
348
- constructor to create the object and then map argument values to its properties. This is
349
- repeated recursively, using all nested argument values and creating nested target objects
350
- accordingly. For example:
346
+ injected into the handler method. If the target object is not a simple Java type, binding
347
+ is performed through a primary data constructor, and this is repeated recursively by using
348
+ nested argument values to invoke the constructors of nested target objects. For example:
351
349
352
350
[source,java,indent=0,subs="verbatim,quotes"]
353
351
----
@@ -366,15 +364,18 @@ accordingly. For example:
366
364
}
367
365
----
368
366
369
- TIP: If the target object doesn't have setters, and you can't change that, you can use a
370
- property on `AnnotatedControllerConfigurer` to allow falling back on binding via direct
371
- field access.
367
+ Alternatively, binding can also be done by invoking a default constructor first, and then
368
+ applying argument values via setters on the target object.
372
369
373
- By default, if the method parameter name is available (requires the `-parameters` compiler
374
- flag with Java 8+ or debugging info from the compiler), it is used to look up the argument.
375
- If needed, you can customize the name through the annotation, e.g. `@Argument("bookInput")`.
370
+ TIP: If the target object doesn't have setters, and you can't change that, you can
371
+ configure the argument binder to fall back on binding via direct field access.
376
372
377
- TIP: The `@Argument` annotation does not have a "required" flag, nor the option to
373
+ By default, if the method parameter name is available, for example with the `-parameters`
374
+ compiler flag in Java 8+ or with debugging info from the compiler, it is used to look up
375
+ the argument. If necessary, you can customize the name through the annotation, for example
376
+ `@Argument("bookInput")`.
377
+
378
+ Note that the `@Argument` annotation does not have a "required" flag, nor the option to
378
379
specify a default value. Both of these can be specified at the GraphQL schema level and
379
380
are enforced by GraphQL Java.
380
381
@@ -396,11 +397,11 @@ the argument. For example:
396
397
}
397
398
----
398
399
399
- NOTE: Prior to 1.2, `@Argument Map<String, Object>` returned the full arguments map if
400
- the annotation did not specify a name. After 1.2, `@Argument` with
401
- `Map<String, Object>` always returns the raw argument value, matching either to the name
402
- specified in the annotation, or to the parameter name . For access to the full arguments
403
- map, please use xref:controllers.adoc#controllers.schema-mapping.arguments[`@Arguments`] instead.
400
+ NOTE: Prior to 1.2, `@Argument Map<String, Object>` returned the full arguments map when
401
+ the annotation did not specify a name. After 1.2, `@Argument Map<String, Object>` always
402
+ returns the raw argument value, either based on the parameter name or the name in the
403
+ annotation. For access to the full arguments map, please use
404
+ xref:controllers.adoc#controllers.schema-mapping.arguments[`@Arguments`] instead.
404
405
405
406
406
407
[[controllers.schema-mapping.argument-value]]
0 commit comments