File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
main/java/org/springframework/graphql/execution
test/java/org/springframework/graphql/execution Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 4949
5050import org .springframework .beans .BeanUtils ;
5151import org .springframework .beans .BeansException ;
52+ import org .springframework .core .MethodParameter ;
5253import org .springframework .core .ReactiveAdapter ;
5354import org .springframework .core .ReactiveAdapterRegistry ;
5455import org .springframework .core .ResolvableType ;
@@ -522,6 +523,13 @@ private static void addReflectionClassResolver(
522523int index = clazz .getName ().indexOf (clazz .getSimpleName ());
523524resolver .addClassPrefix (outputTypeName , clazz .getName ().substring (0 , index ));
524525}
526+ else if (fieldEntry .getValue () instanceof SelfDescribingDataFetcher <?> sddf ) {
527+ if (sddf .getReturnType ().getSource () instanceof MethodParameter param ) {
528+ clazz = param .getDeclaringClass ();
529+ int index = clazz .getName ().indexOf (clazz .getSimpleName ());
530+ resolver .addClassPrefix (outputTypeName , clazz .getName ().substring (0 , index ));
531+ }
532+ }
525533}
526534}
527535}
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ public class SchemaMappingInspectorUnionTests extends SchemaMappingInspectorTest
5151class InterfaceFieldsNotOnJavaInterface {
5252
5353@ Test
54- void reportUnmappedFields () {
54+ void reportUnmappedFieldsByCheckingReturnTypePackage () {
5555SchemaReport report = inspectSchema (schema , SearchController .class );
5656assertThatReport (report )
5757.hasSkippedTypeCount (0 )
@@ -60,6 +60,16 @@ void reportUnmappedFields() {
6060.containsUnmappedFields ("Video" , "title" );
6161}
6262
63+ @ Test
64+ void reportUnmappedFieldsByCheckingControllerTypePackage () {
65+ SchemaReport report = inspectSchema (schema , ObjectSearchController .class );
66+ assertThatReport (report )
67+ .hasSkippedTypeCount (0 )
68+ .hasUnmappedFieldCount (3 )
69+ .containsUnmappedFields ("Photo" , "height" , "width" )
70+ .containsUnmappedFields ("Video" , "title" );
71+ }
72+
6373
6474sealed interface ResultItem permits Photo , Video { }
6575record Photo () implements ResultItem { }
@@ -73,6 +83,16 @@ List<ResultItem> search() {
7383throw new UnsupportedOperationException ();
7484}
7585}
86+
87+
88+ @ Controller
89+ static class ObjectSearchController {
90+
91+ @ QueryMapping
92+ List <Object > search () {
93+ throw new UnsupportedOperationException ();
94+ }
95+ }
7696}
7797
7898
You can’t perform that action at this time.
0 commit comments