39
39
import graphql .schema .GraphQLList ;
40
40
import graphql .schema .GraphQLNonNull ;
41
41
import graphql .schema .GraphQLObjectType ;
42
- import graphql .schema .GraphQLOutputType ;
43
42
import graphql .schema .GraphQLSchemaElement ;
44
43
import graphql .schema .GraphQLType ;
45
44
import graphql .schema .GraphQLTypeVisitorStub ;
@@ -153,7 +152,7 @@ private static GraphQLObjectType getAsObjectType(@Nullable GraphQLFieldDefinitio
153
152
@ Nullable
154
153
private static GraphQLObjectType getEdgeType (@ Nullable GraphQLFieldDefinition field ) {
155
154
if (getType (field ) instanceof GraphQLList listType ) {
156
- if (listType .getWrappedType () instanceof GraphQLObjectType type ) {
155
+ if (unwrapNonNullType ( listType .getWrappedType () ) instanceof GraphQLObjectType type ) {
157
156
return type ;
158
157
}
159
158
}
@@ -165,7 +164,14 @@ private static GraphQLType getType(@Nullable GraphQLFieldDefinition field) {
165
164
if (field == null ) {
166
165
return null ;
167
166
}
168
- GraphQLOutputType type = field .getType ();
167
+ return unwrapNonNullType (field .getType ());
168
+ }
169
+
170
+ @ Nullable
171
+ private static GraphQLType unwrapNonNullType (@ Nullable GraphQLType type ) {
172
+ if (type == null ) {
173
+ return null ;
174
+ }
169
175
return (type instanceof GraphQLNonNull nonNullType ) ? nonNullType .getWrappedType () : type ;
170
176
}
171
177
@@ -184,14 +190,16 @@ public static ConnectionFieldTypeVisitor create(List<ConnectionAdapter> adapters
184
190
185
191
/**
186
192
* {@code DataFetcher} decorator that adapts return values with an adapter.
193
+ * @param delegate the datafetcher delegate
194
+ * @param adapter the connection adapter to use
187
195
*/
188
- private record ConnectionDataFetcher (DataFetcher <?> delegate , ConnectionAdapter adapter ) implements DataFetcher <Object > {
196
+ record ConnectionDataFetcher (DataFetcher <?> delegate , ConnectionAdapter adapter ) implements DataFetcher <Object > {
189
197
190
198
private static final Connection <?> EMPTY_CONNECTION =
191
199
new DefaultConnection <>(Collections .emptyList (), new DefaultPageInfo (null , null , false , false ));
192
200
193
201
194
- private ConnectionDataFetcher {
202
+ ConnectionDataFetcher {
195
203
Assert .notNull (delegate , "DataFetcher delegate is required" );
196
204
Assert .notNull (adapter , "ConnectionAdapter is required" );
197
205
}
0 commit comments