Skip to content

Commit 1e811fe

Browse files
author
Thomas Draier
committed
Simplified test for isConnection(), test object type on a list of predefined class
1 parent bcb65c0 commit 1e811fe

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/java/graphql/annotations/GraphQLAnnotations.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public class GraphQLAnnotations implements GraphQLAnnotationsProcessor {
8282

8383
private static final Relay RELAY_TYPES = new Relay();
8484

85+
private static final List<Class> TYPES_FOR_CONNECTION = Arrays.asList(GraphQLObjectType.class, GraphQLInterfaceType.class, GraphQLUnionType.class, GraphQLTypeReference.class);
86+
8587
private Map<String, graphql.schema.GraphQLType> typeRegistry = new HashMap<>();
8688
private final Stack<String> processing = new Stack<>();
8789

@@ -510,11 +512,7 @@ private GraphQLOutputType getGraphQLConnection(boolean isConnection, AccessibleO
510512

511513
private boolean isConnection(AccessibleObject obj, Class<?> klass, GraphQLOutputType type) {
512514
return obj.isAnnotationPresent(GraphQLConnection.class) &&
513-
type instanceof GraphQLList &&
514-
(((GraphQLList) type).getWrappedType() instanceof GraphQLObjectType ||
515-
((GraphQLList) type).getWrappedType() instanceof GraphQLInterfaceType ||
516-
((GraphQLList) type).getWrappedType() instanceof GraphQLUnionType ||
517-
((GraphQLList) type).getWrappedType() instanceof GraphQLTypeReference);
515+
type instanceof GraphQLList && TYPES_FOR_CONNECTION.stream().anyMatch(aClass -> aClass.isInstance(((GraphQLList) type).getWrappedType()));
518516
}
519517

520518
protected GraphQLFieldDefinition getField(Method method) throws GraphQLAnnotationsException {

0 commit comments

Comments
 (0)