Skip to content

Commit 02a581f

Browse files
committed
fix: missing targetNames in hasOne reference
1 parent 61e0f8f commit 02a581f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/appsync-modelgen-plugin/src/__tests__/visitors/__snapshots__/appsync-model-introspection-visitor.test.ts.snap

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3692,7 +3692,8 @@ exports[`custom references double linked references 1`] = `
36923692
\\"connectionType\\": \\"HAS_ONE\\",
36933693
\\"associatedWith\\": [
36943694
\\"bar1Id\\"
3695-
]
3695+
],
3696+
\\"targetNames\\": []
36963697
}
36973698
},
36983699
\\"bar2\\": {
@@ -3707,7 +3708,8 @@ exports[`custom references double linked references 1`] = `
37073708
\\"connectionType\\": \\"HAS_ONE\\",
37083709
\\"associatedWith\\": [
37093710
\\"bar2Id\\"
3710-
]
3711+
],
3712+
\\"targetNames\\": []
37113713
}
37123714
},
37133715
\\"createdAt\\": {
@@ -4244,7 +4246,8 @@ exports[`custom references sets the association to the references field for hasO
42444246
\\"connectionType\\": \\"HAS_ONE\\",
42454247
\\"associatedWith\\": [
42464248
\\"primaryId\\"
4247-
]
4249+
],
4250+
\\"targetNames\\": []
42484251
}
42494252
},
42504253
\\"createdAt\\": {
@@ -4467,7 +4470,8 @@ exports[`custom references sets the association to the references field for hasO
44674470
\\"connectionType\\": \\"HAS_ONE\\",
44684471
\\"associatedWith\\": [
44694472
\\"primaryId\\"
4470-
]
4473+
],
4474+
\\"targetNames\\": []
44714475
}
44724476
},
44734477
\\"createdAt\\": {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class AppSyncModelIntrospectionVisitor<
115115
connectionAttribute.associatedWith = connectionInfo.associatedWithFields.map(f => this.getFieldName(f));
116116
} else if (connectionInfo.kind === CodeGenConnectionType.HAS_ONE) {
117117
connectionAttribute.associatedWith = connectionInfo.associatedWithFields.map(f => this.getFieldName(f));
118-
connectionAttribute.targetNames = connectionInfo.targetNames;
118+
connectionAttribute.targetNames = connectionInfo.targetNames ?? [];
119119
} else {
120120
connectionAttribute.targetNames = connectionInfo.targetNames;
121121
}

0 commit comments

Comments
 (0)