aws-amplify / aws-amplify/amplify-studio
Data modeling generates wrong schema
- Dominant language
- No language data
- Stars
- 135
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-adminui/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-adminui/blob/main/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.
### App Id
/dsuhzpzj2hmel/dev/datastore
### Region
eu-central-1
### Environment name
dev
### Figma File Version (if applicable)
_No response_
### Amplify CLI Version
10.6.1
### If applicable, what version of Node.js are you using?
_No response_
### What operating system are you using?
Mac
### Browser type?
Safari
### Describe the bug
I add three models idea, location, profile
Locations is 1:n relationship to profile and ideas, so one location can belong to many profiles and many ideas.
If I create these relationships between the models in visual editor, the code generated for the graphql creates wrong code.
This is the code generated
```
locationID: ID! @index(name: "byLocation")
location: Location @belongsTo(fields: ["locationID"])
profileID: ID! @index(name: "byProfile")
profile: Profile @belongsTo(fields: ["locationID"])
```
The last line contains the error.
### Expected behavior
I would expect the following result
```
locationID: ID! @index(name: "byLocation")
location: Location @belongsTo(fields: ["locationID"])
profileID: ID! @index(name: "byProfile")
profile: Profile @belongsTo(fields: ["**profile**ID"])
```
### Reproduction steps
Create three models
Create two 1:n relationships in the visual editor
Change to graphQL scheme
### Project Identifier
_No response_
### Additional information
Workaround is to create the file in visual editor, deploy it, fix it locally and push it back
It would also be good, if the relationship name suggestion would be lowercase, as the uppercase creates problems with dart models.
Contributor guide
Research direction
Reproduce the issue by creating the three models and two 1:n relationships in the visual editor, then inspect the generated GraphQL schema. Trace how the second relationship field is generated and confirm that it uses profileID rather than locationID. Verify the corrected schema and consider the reported lowercase relationship-name concern separately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100