17
17
package org .springframework .graphql .data .federation ;
18
18
19
19
import java .lang .reflect .Method ;
20
+ import java .util .ArrayList ;
20
21
import java .util .LinkedHashMap ;
21
22
import java .util .List ;
22
23
import java .util .Map ;
67
68
* @author Rossen Stoyanchev
68
69
* @since 1.3.0
69
70
* @see Federation#transform(TypeDefinitionRegistry, RuntimeWiring)
70
- *
71
71
*/
72
72
public final class FederationSchemaFactory
73
73
extends AnnotatedControllerDetectionSupport <FederationSchemaFactory .EntityMappingInfo > {
@@ -80,7 +80,7 @@ public final class FederationSchemaFactory
80
80
81
81
/**
82
82
* Configure a resolver that helps to map Java to entity schema type names.
83
- * <p>By default this is {@link ClassNameTypeResolver}.
83
+ * <p>By default, this is {@link ClassNameTypeResolver}.
84
84
* @param typeResolver the custom type resolver to use
85
85
* @see SchemaTransformer#resolveEntityType(TypeResolver)
86
86
*/
@@ -186,13 +186,19 @@ public SchemaTransformer createSchemaTransformer(TypeDefinitionRegistry registry
186
186
}
187
187
188
188
private void checkEntityMappings (TypeDefinitionRegistry registry ) {
189
+ List <String > unmappedEntities = new ArrayList <>();
189
190
for (TypeDefinition <?> type : registry .types ().values ()) {
190
191
type .getDirectives ().forEach ((directive ) -> {
191
192
boolean isEntityType = directive .getName ().equalsIgnoreCase ("key" );
192
- Assert .state (!isEntityType || this .handlerMethods .containsKey (type .getName ()),
193
- "No EntityMapping method for federated type: '" + type .getName () + "'" );
193
+ if (isEntityType && !this .handlerMethods .containsKey (type .getName ())) {
194
+ unmappedEntities .add (type .getName ());
195
+ }
194
196
});
195
197
}
198
+ if (!unmappedEntities .isEmpty ()) {
199
+ throw new IllegalStateException ("Unmapped entity types: " +
200
+ unmappedEntities .stream ().collect (Collectors .joining ("', '" , "'" , "'" )));
201
+ }
196
202
}
197
203
198
204
0 commit comments