Skip to content

Commit

Permalink
Add targetNames to belongsTo
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerjroach committed Sep 25, 2023
1 parent 413d2b9 commit 1fb6644
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public final class Project implements Model {
public static final QueryField PROJECT_TEAM_NAME = field(\\"Project\\", \\"projectTeamName\\");
private final @ModelField(targetType=\\"ID\\", isRequired = true) String projectId;
private final @ModelField(targetType=\\"String\\", isRequired = true) String name;
private final @ModelField(targetType=\\"Team\\") @HasOne(associatedWith = \\"project\\", type = Team.class) Team team = null;
private final @ModelField(targetType=\\"Team\\") @HasOne(associatedWith = \\"project\\", targetNames = {\\"projectTeamTeamId\\", \\"projectTeamName\\"}, type = Team.class) Team team = null;
private @ModelField(targetType=\\"AWSDateTime\\", isReadOnly = true) Temporal.DateTime createdAt;
private @ModelField(targetType=\\"AWSDateTime\\", isReadOnly = true) Temporal.DateTime updatedAt;
private final @ModelField(targetType=\\"ID\\") String projectTeamTeamId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,10 @@ export class AppSyncModelJavaVisitor<
case CodeGenConnectionType.HAS_ONE:
connectionDirectiveName = 'HasOne';
connectionArguments.push(`associatedWith = "${this.getFieldName(connectionInfo.associatedWith)}"`);
if (this.isCustomPKEnabled()) {
const hasOneTargetNamesArgs = `targetNames = {${connectionInfo.targetNames.map(target => `"${target}"`).join(', ')}}`;
connectionArguments.push(hasOneTargetNamesArgs);
}
break;
case CodeGenConnectionType.HAS_MANY:
connectionDirectiveName = 'HasMany';
Expand Down

0 comments on commit 1fb6644

Please sign in to comment.