aws-amplify / aws-amplify/amplify-codegen
`ampify codegen model` filters out connection fields
- Dominant language
- TypeScript
- Stars
- 59
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When you have a connection field in your schema, like this:
```js
type Order
@model(subscriptions: null)
@key(name: "ByCustomer", fields: ["customerID"], queryField: "ordersByCustomer")
{
id: ID!
businessID: ID!
customerID: ID!
customer: Customer @connection(fields: ["customerID"])
}
```
The generated models do not include the `customerID` property and instead nest it under `customer.business.id` because it maps business to be of type `Business`.
This is technically not "wrong", but the result still very much includes `customerID` when queries and now the models don't line up anymore. Reading the result as `customer.business.id` probably works, but it's not the most efficient.
**Amplify CLI Version**
4.41.1
**To Reproduce**
Create a schema with a connection field.
Run codegen for models.
See the property is missing.
**Expected behavior**
Property to still be included.
**Screenshots**
Missing property in the models.

TS error when using the model

**Desktop (please complete the following information):**
- OS: MacOS 10.15.7
- Node Version. 12.19.0
Contributor guide
Assessment
This issue has not been assessed yet.