Skip to content

Commit e5e5f84

Browse files
committed
fix @GraphQLConnection for [ObjectType!]!
1 parent 5be7198 commit e5e5f84

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/main/java/graphql/annotations/processor/util/ConnectionUtil.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,24 @@ public class ConnectionUtil {
3333
private static final List<Class> TYPES_FOR_CONNECTION = Arrays.asList(GraphQLObjectType.class, GraphQLInterfaceType.class, GraphQLUnionType.class, GraphQLTypeReference.class);
3434

3535
public static boolean isConnection(AccessibleObject obj, GraphQLType type) {
36+
if (!obj.isAnnotationPresent(GraphQLConnection.class)) {
37+
return false;
38+
}
39+
40+
if (type instanceof graphql.schema.GraphQLNonNull) {
41+
type = ((GraphQLNonNull) type).getWrappedType();
42+
}
43+
if (!(type instanceof GraphQLList)) {
44+
return false;
45+
}
46+
47+
type = ((GraphQLList) type).getWrappedType();
3648
if (type instanceof graphql.schema.GraphQLNonNull) {
3749
type = ((GraphQLNonNull) type).getWrappedType();
3850
}
39-
final GraphQLType actualType = type;
40-
boolean isValidGraphQLTypeForConnection = obj.isAnnotationPresent(GraphQLConnection.class) &&
41-
actualType instanceof GraphQLList && TYPES_FOR_CONNECTION.stream().anyMatch(aClass ->
42-
aClass.isInstance(((GraphQLList) actualType).getWrappedType()));
51+
52+
final GraphQLType elementType = type;
53+
boolean isValidGraphQLTypeForConnection = TYPES_FOR_CONNECTION.stream().anyMatch(aClass -> aClass.isInstance(elementType));
4354

4455
if (isValidGraphQLTypeForConnection) {
4556
ConnectionValidator validator = newInstance(obj.getAnnotation(GraphQLConnection.class).validator());

0 commit comments

Comments
 (0)