aws-amplify / aws-amplify/amplify-codegen

`ampify codegen model` filters out connection fields

Open
#214 4 comments 0 reactions 0 assignees View on GitHub
bug p2 type-gen
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.
![image](https://user-images.githubusercontent.com/1668207/104495536-e2533200-55a5-11eb-9daf-77c56f3fba50.png)

TS error when using the model
![image](https://user-images.githubusercontent.com/1668207/104495463-cd769e80-55a5-11eb-8ada-af5cf125d4ff.png)

**Desktop (please complete the following information):**
- OS: MacOS 10.15.7
- Node Version. 12.19.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.