@@ -77,8 +77,38 @@ For example:
77
77
}
78
78
----
79
79
80
- The `@Argument` method parameters is resolved from the "representation" input map for the entity.
81
- You can also inject the full "representation" input `Map`.
80
+ The `@Argument` method parameters is resolved from the "representation" input map for
81
+ the entity. You can also inject the full "representation" input `Map`. See
82
+ xref:federation.adoc#federation.entity-mapping.signature[Method Signature] for all
83
+ supported method argument and return value types.
84
+
85
+ You can batch load federated entities by returning a `List` of instances from the controller
86
+ method and accepting a `List` of argument values. In addition, you can use `@BatchMapping`
87
+ methods for subfields.
88
+
89
+ For example:
90
+
91
+ [source,java,indent=0,subs="verbatim,quotes"]
92
+ ----
93
+ @Controller
94
+ private static class BookController {
95
+
96
+ @EntityMapping
97
+ public List<Book> book(@Argument List<Integer> idList) {
98
+ // ...
99
+ }
100
+
101
+ @BatchMapping
102
+ public Map<Book, Author> author(List<Book> books) {
103
+ // ...
104
+ }
105
+ }
106
+ ----
107
+
108
+ Note `idList` naming convention for the argument, which helps Spring for GraphQL to
109
+ de-pluralize the method parameter name and derive the correct argument name to use.
110
+ Alternatively, set the argument name through the annotation.
111
+
82
112
83
113
84
114
[[federation.entity-mapping.signature]]
@@ -96,6 +126,10 @@ Entity mapping methods support the following arguments:
96
126
| `Map<String, Object>`
97
127
| The full "representation" input map for the entity.
98
128
129
+ | `List<Map<String, Object>>`
130
+ | The list of "representation" input maps when using a single controller method to load
131
+ all entities of a given type.
132
+
99
133
| `@ContextValue`
100
134
| For access to an attribute from the main `GraphQLContext` in `DataFetchingEnvironment`.
101
135
@@ -132,4 +166,3 @@ You can use `@GraphQlExceptionHandler` methods to map exceptions from `@EntityMa
132
166
methods to ``GraphQLError``'s. The errors will be included in the response of the
133
167
"_entities" query. Exception handler methods can be in the same controller or in an
134
168
`@ControllerAdvice` class.
135
-
0 commit comments