Skip to content

Commit 7d843d8

Browse files
committed
fix xtext visitor handling recursive types
1 parent 6c9ea7a commit 7d843d8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/com/intuit/graphql/orchestrator/utils/XtextToGraphQLJavaVisitor.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,14 @@ public GraphQLSchemaElement caseObjectTypeDefinition(final ObjectTypeDefinition
197197

198198
GraphQLType graphQLType = graphQLObjectTypes.get(me);
199199
if (Objects.nonNull(graphQLType)) {
200-
int cachedFieldSize = ((GraphQLObjectType) graphQLType).getFieldDefinitions().size();
201-
int incomingFieldSize = object.getFieldDefinition().size();
202-
//No need to check types with same field size and with different fields b/c it would conflict earlier on and would fail to stitch
203-
if(cachedFieldSize != incomingFieldSize && !typesWithInaccessibleFields.contains(me)) {
204-
String conflictingNamespace = (cachedFieldSize > incomingFieldSize) ? ((GraphQLObjectType) graphQLType).getDescription() : object.getDesc();
205-
throw new StitchingException(String.format(ERRMSG_REUSED_CONFLICTING_TYPE, conflictingNamespace, me));
200+
if(graphQLType instanceof GraphQLObjectType) {
201+
int cachedFieldSize = ((GraphQLObjectType) graphQLType).getFieldDefinitions().size();
202+
int incomingFieldSize = object.getFieldDefinition().size();
203+
//No need to check types with same field size and with different fields b/c it would conflict earlier on and would fail to stitch
204+
if(cachedFieldSize != incomingFieldSize && !typesWithInaccessibleFields.contains(me)) {
205+
String conflictingNamespace = (cachedFieldSize > incomingFieldSize) ? ((GraphQLObjectType) graphQLType).getDescription() : object.getDesc();
206+
throw new StitchingException(String.format(ERRMSG_REUSED_CONFLICTING_TYPE, conflictingNamespace, me));
207+
}
206208
}
207209
return graphQLType;
208210
}

0 commit comments

Comments
 (0)