aws-amplify / aws-amplify/amplify-codegen

Amplify codegen models is creating id when primarykey is specified

Open
#424 8 comments 2 reactions 0 assignees View on GitHub
bug p3 transferred
Dominant language
TypeScript
Stars
59
Forks
64
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.

### How did you install the Amplify CLI?

npm

### If applicable, what version of Node.js are you using?

v16.14.0

### Amplify CLI Version

8.0.3

### What operating system are you using?

Mac

### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

### Amplify Categories

api

### Amplify Commands

codegen

### Describe the bug

When specifying the following model.
```
type Todo @model {
key: ID! @primaryKey
name: String!
description: String
}
```

I'm still getting an id field in the files created by `amplify codegen models`

### Expected behavior

I expect the DataStore to adhere to the primaryKey directive.

### Reproduction steps

Create a schema as described and then do `amplify codegen models`

### GraphQL schema(s)

```graphql
type Todo @model {
key: ID! @primaryKey
name: String!
description: String
}

```

### Log output

```
# Put your logs below this line

```

### Additional information

schema.js

```
export const schema = {
"models": {
"Todo": {
"name": "Todo",
"fields": {
"id": {
"name": "id",
"isArray": false,
"type": "ID",
"isRequired": true,
"attributes": []
},
"key": {
"name": "key",
"isArray": false,
"type": "ID",
"isRequired": true,
"attributes": []
},
"name": {
"name": "name",
"isArray": false,
"type": "String",
"isRequired": true,
"attributes": []
},
"description": {
"name": "description",
"isArray": false,
"type": "String",
"isRequired": false,
"attributes": []
},
"createdAt": {
"name": "createdAt",
"isArray": false,
"type": "AWSDateTime",
"isRequired": false,
"attributes": [],
"isReadOnly": true
},
"updatedAt": {
"name": "updatedAt",
"isArray": false,
"type": "AWSDateTime",
"isRequired": false,
"attributes": [],
"isReadOnly": true
}
},
"syncable": true,
"pluralName": "Todos",
"attributes": [
{
"type": "model",
"properties": {}
},
{
"type": "key",
"properties": {
"fields": [
"key"
]
}
}
]
}
},
"enums": {},
"nonModels": {},
"version": "fe2b4ee8f0b0a06f4de46e98893aaf50"
};
```

Additionally it looks like when using the Datastore the subscriptions are looking for the id column which doesn't exist on the server.

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.