Skip to content

Commit 1d95cb4

Browse files
committed
fix
1 parent bad782c commit 1d95cb4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,11 @@ export class AppSyncModelVisitor<
11841184
connectionInfo.targetName !== 'id'
11851185
) {
11861186
// Need to remove the field that is targetName
1187-
connectionInfo.targetNames.forEach(targetName => removeFieldFromModel(model, targetName));
1187+
// Don't remove the field if it is a primary key field
1188+
const primaryKeyFieldNames = getModelPrimaryKeyComponentFields(model).map(field => field.name);
1189+
connectionInfo.targetNames
1190+
.filter(targetName => !primaryKeyFieldNames.includes(targetName))
1191+
.forEach(targetName => removeFieldFromModel(model, targetName));
11881192
}
11891193
});
11901194
});

0 commit comments

Comments
 (0)