23
23
import java .util .function .Function ;
24
24
25
25
import graphql .schema .DataFetchingFieldSelectionSet ;
26
+ import graphql .schema .GraphQLNamedOutputType ;
26
27
import graphql .schema .SelectedField ;
27
28
28
29
import org .springframework .data .mapping .PropertyPath ;
@@ -83,6 +84,12 @@ private static List<PropertyPath> getPropertyPaths(
83
84
String propertyName = selectedField .getName ();
84
85
TypeInformation <?> propertyTypeInfo = typeInfo .getProperty (propertyName );
85
86
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
+ }
86
93
continue ;
87
94
}
88
95
@@ -102,6 +109,30 @@ private static List<PropertyPath> getPropertyPaths(
102
109
return result ;
103
110
}
104
111
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
+
105
136
106
137
/**
107
138
* Hierarchical representation of selected fields. Allows traversing the
0 commit comments