-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't save One to Many Models Using Data Store #1442
Comments
Hello @irisk29 - Thanks for opening the issue. A few questions:
|
Hello @Jordan-Nelson, |
What was happening when you attempted to save without a shopping bag connected to the product? Was there an exception thrown? |
No exception was thrown, nothing happened. The state of the information in the cloud was like in the pictures attached. |
Do you mind explaining what you mean by this? Were you able to get this to work by changing either your schema, or the code being run? |
I had to change the code being run. I needed to create the ShoppingBagModel, save it, and then connect the ID of it to the product of the store I wanted to create. |
@irisk29 - The schema that you shared only has |
|
Thanks @Jordan-Nelson for the initial triaging. When a field is used as a Global Secondary Index -
The underlying GraphQL mutation will be rejected by DynamoDB as this field will be assigned a There is no convenient workaround now unfortunately to 100% replicate your current model structure. (I believe you created the models using Amplify Studio data modeling interface?) Here's what I do to get around of this personally.
type ProductModel @model @auth(rules: [{allow: public}]) {
id: ID!
name: String
categories: AWSJSON
price: Float
imageUrl: String
description: String
onlinestoremodelID: ID @index(name: "byOnlineStoreModel")
onlineStore: OnlineStoreModel @belongsTo(fields: ["onlinestoremodelID"])
shoppingbagmodelID: ID @index(name: "byShoppingBagModel")
shoppingBag: ShoppingBagModel @belongsTo(fields: ["shoppingbagmodelID"])
}
Please note that currently Amplify Studio Data modeling interface doesn't support I'm going to close this issue in favor of #306 . Please feel to follow up if you have any other question. |
Description
Hello,
I'm trying to save via Data Store Product that is connected to Store (one Store has many Products).
The store is saved successfully (I can see it in the content section in AWS amplify studio) but not the product.
I have tried in many ways -
but nothing works, I could never see the product in the content section.
Categories
Steps to Reproduce
the schema is:
This is the code that I'm performing:
Screenshots
Platforms
Environment
Dependencies
Device
iPhone 13
OS
iOS 15.0.0
CLI Version
7.6.22
Additional Context
No response
The text was updated successfully, but these errors were encountered: