2323import java .util .function .Function ;
2424
2525import graphql .schema .DataFetchingFieldSelectionSet ;
26+ import graphql .schema .GraphQLNamedOutputType ;
2627import graphql .schema .SelectedField ;
2728
2829import org .springframework .data .mapping .PropertyPath ;
@@ -83,6 +84,12 @@ private static List<PropertyPath> getPropertyPaths(
8384 String propertyName = selectedField .getName ();
8485 TypeInformation <?> propertyTypeInfo = typeInfo .getProperty (propertyName );
8586 if (propertyTypeInfo == null ) {
87+ if (isConnectionEdges (selectedField )) {
88+ getConnectionPropertyPaths (typeInfo , selection , pathFactory , selectedField , result );
89+ }
90+ else if (isConnectionEdgeNode (selectedField )) {
91+ getConnectionPropertyPaths (typeInfo , selection , pathFactory , selectedField , result );
92+ }
8693 continue ;
8794 }
8895
@@ -102,6 +109,30 @@ private static List<PropertyPath> getPropertyPaths(
102109 return result ;
103110 }
104111
112+ private static boolean isConnectionEdges (SelectedField selectedField ) {
113+ return selectedField .getName ().equals ("edges" ) &&
114+ selectedField .getParentField ().getType () instanceof GraphQLNamedOutputType namedType &&
115+ namedType .getName ().endsWith ("Connection" );
116+ }
117+
118+ private static boolean isConnectionEdgeNode (SelectedField selectedField ) {
119+ return selectedField .getName ().equals ("node" ) && isConnectionEdges (selectedField .getParentField ());
120+ }
121+
122+ private static void getConnectionPropertyPaths (
123+ TypeInformation <?> typeInfo , FieldSelection selection , Function <String , PropertyPath > pathFactory ,
124+ SelectedField selectedField , List <PropertyPath > result ) {
125+
126+ FieldSelection nestedSelection = selection .select (selectedField );
127+ if (!nestedSelection .isEmpty ()) {
128+ TypeInformation <?> actualType = typeInfo .getRequiredActualType ();
129+ List <PropertyPath > paths = getPropertyPaths (actualType , nestedSelection , pathFactory );
130+ if (!CollectionUtils .isEmpty (paths )) {
131+ result .addAll (paths );
132+ }
133+ }
134+ }
135+
105136
106137 /**
107138 * Hierarchical representation of selected fields. Allows traversing the
0 commit comments