aws-amplify / aws-amplify/amplify-codegen
@default directive cannot be applied when use DataStore in LOCAL only mode
- 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-codegen/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-codegen/blob/master/CONTRIBUTING.md#bugs).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
### How did you install the Amplify CLI?
_No response_
### If applicable, what version of Node.js are you using?
_No response_
### Amplify CLI Version
7.6.3
### What operating system are you using?
Mac
### Amplify Codegen Command
codegen models
### Describe the bug
When generate models for a schema using `@default` directive, the default value is not generated in the generated models. Therefore the default value won't be set when cloud sync is not enabled, if I want to apply the default value, the data has to be written into DynamoDB and sync back to my local DataStore.
### Expected behavior
When using DataStore with LOCAL only mode, the value defined in `@default` directive should also be applied.
### Reproduction steps
1. `amplify codegen models` with the example schema
2. observe generated models
### GraphQL schema(s)
```graphql
type ModelWithDefaultValue @model {
id: ID!
content: String @default(value: "default content")
}
```
### Log output
```
# Put your logs below this line
```
### Additional information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.