Skip to content

Commit ead747d

Browse files
authored
Merge pull request #329 from aws-amplify/fix320
fix(appsync-modelgen-plugin):remove fields in second loop
2 parents cc30e73 + 0b0b075 commit ead747d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 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,19 @@ 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
730+
&& connectionInfo.kind !== CodeGenConnectionType.HAS_MANY
731+
&& connectionInfo.kind !== CodeGenConnectionType.HAS_ONE
732+
&& connectionInfo.targetName !== 'id') {
733+
// Need to remove the field that is targetName
734+
removeFieldFromModel(model, connectionInfo.targetName);
735+
}
736+
});
737+
})
729738
}
730739

731740
protected processV2KeyDirectives(): void {

0 commit comments

Comments
 (0)