Open crestswapnil opened 4 months ago
Hi @crestswapnil, can you check the network activity for the graphql mutation that is sent to AppSync? I'm curious what the graphql request string looks like vs the query that works on refresh.
This was the graphQL query string while saving the data,
And this is the query when I refresh the page,
@chrisbonifacio Any updates on this? Please help me I'm badly stuck in this.
Can anyone help me to solve this? It's been 4 days...
The error you shared message seems to indicate that the ID
field in Restaurant
is null
. This would suggest that the Restaurant
object AppSync is looking for doesn't actually exist.
Can you confirm that you are saving the Restaurant
object (and await
-ing) before saving the Ingredient
?
@svidgen Yes it is confirmed that the Restaurant
object is being saved properly.
@crestswapnil Can you try something for me ? I think I have the same bug as you and I managed to "fix" it by reverting some VTL in the resolvers.
Could you paste the resolver for Ingredient/restaurant and Ingredient/restaurantIngredientId ? all the request functions for both.
@crestswapnil another thing:
Add "subscriptionsInheritPrimaryAuth": true,
to ./amplify/cli.json features.graphqltransformer
This fixed it for me. Check out the warning as the beginning of this page for more info: https://docs.amplify.aws/gen1/javascript/build-a-backend/graphqlapi/subscribe-data/
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
GraphQL API, DataStore
Amplify Version
v6
Amplify Categories
api
Backend
Amplify CLI
Environment information
Describe the bug
I'm trying to insert an item in the Ingredient table. It has a field called Restaurant which
@belongsTo
Restaurant table.Following is the generated interface for the table schema using the
amplify codegen model
.I tried to save the following data in the Ingredient table.
The data syncs properly to the dynamoDB in the cloud but when Datastore syncs it back to the local, it is replacing the field
restaurantIngredientsId
with null.And when I refresh the page, the data is synced properly back again with the correct value.
I'm also getting the warning while saving the data as,
Expected behavior
The
restaurantIngredientsId
is not getting populated by the data provided when saved using the method,DataStore.save()
. I want the data to be present before I refresh the page when the data is synced after the save.Reproduction steps
amplify codegen model
.amplify push
.DataStore.save(new Ingredient(ingredientData));
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response