Skip to content

Commit 99af55c

Browse files
committed
fix(appsync-modelgen-plugin):remove fields in second loop
1 parent 7a8321b commit 99af55c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/appsync-modelgen-plugin/src/visitors/appsync-visitor.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,6 @@ export class AppSyncModelVisitor<
701701
isList: false,
702702
isNullable: field.isNullable,
703703
});
704-
} else if (connectionInfo.targetName !== 'id') {
705-
// TODO: Remove this branch when we can roll forward.
706-
// Need to remove the field that is targetName, only apply if shouldRevertBreakingKeyChange is set
707-
removeFieldFromModel(model, connectionInfo.targetName);
708704
}
709705
field.connectionInfo = connectionInfo;
710706
}
@@ -726,6 +722,16 @@ export class AppSyncModelVisitor<
726722
return true;
727723
});
728724
});
725+
726+
Object.values(this.modelMap).forEach(model => {
727+
model.fields.forEach(field => {
728+
const connectionInfo = field.connectionInfo;
729+
if (connectionInfo?.kind === CodeGenConnectionType.BELONGS_TO && connectionInfo.targetName !== 'id') {
730+
// Need to remove the field that is targetName
731+
removeFieldFromModel(model, connectionInfo.targetName);
732+
}
733+
});
734+
})
729735
}
730736

731737
protected processV2KeyDirectives(): void {

0 commit comments

Comments
 (0)