Skip to content

Commit de394dd

Browse files
author
Dane Pilcher
authored
fix: do not remove belongsTo target names when using references (#814)
1 parent dd31e18 commit de394dd

9 files changed

+9263
-1
lines changed

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

Lines changed: 3687 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 3073 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4023,6 +4023,195 @@ exports[`custom references hasMany with sortKeyFields on primary key 1`] = `
40234023
}"
40244024
`;
40254025

4026+
exports[`custom references hasOne with sortKeyFields on primary key 1`] = `
4027+
"{
4028+
\\"version\\": 1,
4029+
\\"models\\": {
4030+
\\"Primary\\": {
4031+
\\"name\\": \\"Primary\\",
4032+
\\"fields\\": {
4033+
\\"tenantId\\": {
4034+
\\"name\\": \\"tenantId\\",
4035+
\\"isArray\\": false,
4036+
\\"type\\": \\"ID\\",
4037+
\\"isRequired\\": true,
4038+
\\"attributes\\": []
4039+
},
4040+
\\"instanceId\\": {
4041+
\\"name\\": \\"instanceId\\",
4042+
\\"isArray\\": false,
4043+
\\"type\\": \\"ID\\",
4044+
\\"isRequired\\": true,
4045+
\\"attributes\\": []
4046+
},
4047+
\\"recordId\\": {
4048+
\\"name\\": \\"recordId\\",
4049+
\\"isArray\\": false,
4050+
\\"type\\": \\"ID\\",
4051+
\\"isRequired\\": true,
4052+
\\"attributes\\": []
4053+
},
4054+
\\"content\\": {
4055+
\\"name\\": \\"content\\",
4056+
\\"isArray\\": false,
4057+
\\"type\\": \\"String\\",
4058+
\\"isRequired\\": false,
4059+
\\"attributes\\": []
4060+
},
4061+
\\"related\\": {
4062+
\\"name\\": \\"related\\",
4063+
\\"isArray\\": false,
4064+
\\"type\\": {
4065+
\\"model\\": \\"Related\\"
4066+
},
4067+
\\"isRequired\\": false,
4068+
\\"attributes\\": [],
4069+
\\"association\\": {
4070+
\\"connectionType\\": \\"HAS_ONE\\",
4071+
\\"associatedWith\\": [
4072+
\\"primaryTenantId\\",
4073+
\\"primaryInstanceId\\",
4074+
\\"primaryRecordId\\"
4075+
],
4076+
\\"targetNames\\": []
4077+
}
4078+
},
4079+
\\"createdAt\\": {
4080+
\\"name\\": \\"createdAt\\",
4081+
\\"isArray\\": false,
4082+
\\"type\\": \\"AWSDateTime\\",
4083+
\\"isRequired\\": false,
4084+
\\"attributes\\": [],
4085+
\\"isReadOnly\\": true
4086+
},
4087+
\\"updatedAt\\": {
4088+
\\"name\\": \\"updatedAt\\",
4089+
\\"isArray\\": false,
4090+
\\"type\\": \\"AWSDateTime\\",
4091+
\\"isRequired\\": false,
4092+
\\"attributes\\": [],
4093+
\\"isReadOnly\\": true
4094+
}
4095+
},
4096+
\\"syncable\\": true,
4097+
\\"pluralName\\": \\"Primaries\\",
4098+
\\"attributes\\": [
4099+
{
4100+
\\"type\\": \\"model\\",
4101+
\\"properties\\": {}
4102+
},
4103+
{
4104+
\\"type\\": \\"key\\",
4105+
\\"properties\\": {
4106+
\\"fields\\": [
4107+
\\"tenantId\\",
4108+
\\"instanceId\\",
4109+
\\"recordId\\"
4110+
]
4111+
}
4112+
}
4113+
],
4114+
\\"primaryKeyInfo\\": {
4115+
\\"isCustomPrimaryKey\\": true,
4116+
\\"primaryKeyFieldName\\": \\"tenantId\\",
4117+
\\"sortKeyFieldNames\\": [
4118+
\\"instanceId\\",
4119+
\\"recordId\\"
4120+
]
4121+
}
4122+
},
4123+
\\"Related\\": {
4124+
\\"name\\": \\"Related\\",
4125+
\\"fields\\": {
4126+
\\"id\\": {
4127+
\\"name\\": \\"id\\",
4128+
\\"isArray\\": false,
4129+
\\"type\\": \\"ID\\",
4130+
\\"isRequired\\": true,
4131+
\\"attributes\\": []
4132+
},
4133+
\\"content\\": {
4134+
\\"name\\": \\"content\\",
4135+
\\"isArray\\": false,
4136+
\\"type\\": \\"String\\",
4137+
\\"isRequired\\": false,
4138+
\\"attributes\\": []
4139+
},
4140+
\\"primaryTenantId\\": {
4141+
\\"name\\": \\"primaryTenantId\\",
4142+
\\"isArray\\": false,
4143+
\\"type\\": \\"ID\\",
4144+
\\"isRequired\\": true,
4145+
\\"attributes\\": []
4146+
},
4147+
\\"primaryInstanceId\\": {
4148+
\\"name\\": \\"primaryInstanceId\\",
4149+
\\"isArray\\": false,
4150+
\\"type\\": \\"ID\\",
4151+
\\"isRequired\\": true,
4152+
\\"attributes\\": []
4153+
},
4154+
\\"primaryRecordId\\": {
4155+
\\"name\\": \\"primaryRecordId\\",
4156+
\\"isArray\\": false,
4157+
\\"type\\": \\"ID\\",
4158+
\\"isRequired\\": true,
4159+
\\"attributes\\": []
4160+
},
4161+
\\"primary\\": {
4162+
\\"name\\": \\"primary\\",
4163+
\\"isArray\\": false,
4164+
\\"type\\": {
4165+
\\"model\\": \\"Primary\\"
4166+
},
4167+
\\"isRequired\\": false,
4168+
\\"attributes\\": [],
4169+
\\"association\\": {
4170+
\\"connectionType\\": \\"BELONGS_TO\\",
4171+
\\"targetNames\\": [
4172+
\\"primaryTenantId\\",
4173+
\\"primaryInstanceId\\",
4174+
\\"primaryRecordId\\"
4175+
]
4176+
}
4177+
},
4178+
\\"createdAt\\": {
4179+
\\"name\\": \\"createdAt\\",
4180+
\\"isArray\\": false,
4181+
\\"type\\": \\"AWSDateTime\\",
4182+
\\"isRequired\\": false,
4183+
\\"attributes\\": [],
4184+
\\"isReadOnly\\": true
4185+
},
4186+
\\"updatedAt\\": {
4187+
\\"name\\": \\"updatedAt\\",
4188+
\\"isArray\\": false,
4189+
\\"type\\": \\"AWSDateTime\\",
4190+
\\"isRequired\\": false,
4191+
\\"attributes\\": [],
4192+
\\"isReadOnly\\": true
4193+
}
4194+
},
4195+
\\"syncable\\": true,
4196+
\\"pluralName\\": \\"Relateds\\",
4197+
\\"attributes\\": [
4198+
{
4199+
\\"type\\": \\"model\\",
4200+
\\"properties\\": {}
4201+
}
4202+
],
4203+
\\"primaryKeyInfo\\": {
4204+
\\"isCustomPrimaryKey\\": false,
4205+
\\"primaryKeyFieldName\\": \\"id\\",
4206+
\\"sortKeyFieldNames\\": []
4207+
}
4208+
}
4209+
},
4210+
\\"enums\\": {},
4211+
\\"nonModels\\": {}
4212+
}"
4213+
`;
4214+
40264215
exports[`custom references sets the association to the references field for hasMany/belongsTo 1`] = `
40274216
"{
40284217
\\"version\\": 1,

0 commit comments

Comments
 (0)