3939import graphql .schema .GraphQLList ;
4040import graphql .schema .GraphQLNonNull ;
4141import graphql .schema .GraphQLObjectType ;
42- import graphql .schema .GraphQLOutputType ;
4342import graphql .schema .GraphQLSchemaElement ;
4443import graphql .schema .GraphQLType ;
4544import graphql .schema .GraphQLTypeVisitorStub ;
@@ -153,7 +152,7 @@ private static GraphQLObjectType getAsObjectType(@Nullable GraphQLFieldDefinitio
153152 @ Nullable
154153 private static GraphQLObjectType getEdgeType (@ Nullable GraphQLFieldDefinition field ) {
155154 if (getType (field ) instanceof GraphQLList listType ) {
156- if (listType .getWrappedType () instanceof GraphQLObjectType type ) {
155+ if (unwrapNonNullType ( listType .getWrappedType () ) instanceof GraphQLObjectType type ) {
157156 return type ;
158157 }
159158 }
@@ -165,7 +164,14 @@ private static GraphQLType getType(@Nullable GraphQLFieldDefinition field) {
165164 if (field == null ) {
166165 return null ;
167166 }
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+ }
169175 return (type instanceof GraphQLNonNull nonNullType ) ? nonNullType .getWrappedType () : type ;
170176 }
171177
@@ -184,14 +190,16 @@ public static ConnectionFieldTypeVisitor create(List<ConnectionAdapter> adapters
184190
185191 /**
186192 * {@code DataFetcher} decorator that adapts return values with an adapter.
193+ * @param delegate the datafetcher delegate
194+ * @param adapter the connection adapter to use
187195 */
188- private record ConnectionDataFetcher (DataFetcher <?> delegate , ConnectionAdapter adapter ) implements DataFetcher <Object > {
196+ record ConnectionDataFetcher (DataFetcher <?> delegate , ConnectionAdapter adapter ) implements DataFetcher <Object > {
189197
190198 private static final Connection <?> EMPTY_CONNECTION =
191199 new DefaultConnection <>(Collections .emptyList (), new DefaultPageInfo (null , null , false , false ));
192200
193201
194- private ConnectionDataFetcher {
202+ ConnectionDataFetcher {
195203 Assert .notNull (delegate , "DataFetcher delegate is required" );
196204 Assert .notNull (adapter , "ConnectionAdapter is required" );
197205 }
0 commit comments