Skip to content

Commit e17c696

Browse files
committed
Polishing reference docs on @arguments
See gh-1294
1 parent 29f8337 commit e17c696

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

spring-graphql-docs/modules/ROOT/pages/controllers.adoc

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,9 @@ argument values. The values can be simple scalar values (e.g. String, Long), a `
343343
values for more complex input, or a `List` of values.
344344

345345
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:
351349

352350
[source,java,indent=0,subs="verbatim,quotes"]
353351
----
@@ -366,15 +364,18 @@ accordingly. For example:
366364
}
367365
----
368366

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.
372369

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.
376372

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
378379
specify a default value. Both of these can be specified at the GraphQL schema level and
379380
are enforced by GraphQL Java.
380381

@@ -396,11 +397,11 @@ the argument. For example:
396397
}
397398
----
398399

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.
404405

405406

406407
[[controllers.schema-mapping.argument-value]]

0 commit comments

Comments
 (0)