diff --git a/src/main/java/graphql/schema/GraphQLUnionType.java b/src/main/java/graphql/schema/GraphQLUnionType.java index 9af647c6c4..6910084afd 100644 --- a/src/main/java/graphql/schema/GraphQLUnionType.java +++ b/src/main/java/graphql/schema/GraphQLUnionType.java @@ -96,7 +96,12 @@ public List getTypes() { * @return true if the object type is a member of this union type. */ public boolean isPossibleType(GraphQLObjectType graphQLObjectType) { - return getTypes().stream().anyMatch(nt -> nt.getName().equals(graphQLObjectType.getName())); + for (GraphQLNamedOutputType type : getTypes()) { + if (type.getName().equals(graphQLObjectType.getName())) { + return true; + } + } + return false; } // to be removed in a future version when all code is in the code registry