Skip to content

Commit

Permalink
fix: keep foreign keys on native platforms when they are part of the …
Browse files Browse the repository at this point in the history
…primary key
  • Loading branch information
dpilch committed Oct 2, 2024
1 parent 8801359 commit 47f8cce
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,11 @@ export class AppSyncModelVisitor<
connectionInfo.targetName !== 'id'
) {
// Need to remove the field that is targetName
connectionInfo.targetNames.forEach(targetName => removeFieldFromModel(model, targetName));
// Don't remove the field if it is a primary key field
const primaryKeyFieldNames = getModelPrimaryKeyComponentFields(model).map(field => field.name);
connectionInfo.targetNames
.filter(targetName => !primaryKeyFieldNames.includes(targetName))
.forEach(targetName => removeFieldFromModel(model, targetName));
}
});
});
Expand Down

0 comments on commit 47f8cce

Please sign in to comment.