Closed sansavision closed 2 years ago
Hey @sansavision :wave: thanks for raising this! Using the steps and sample code snippets provided I was able to reproduce this issue and noticed the built UpdateTodoInput
does not include an id
property, leading to a warning from DataStore
# build/schema.graphql
input UpdateTodoInput {
uid: String
username: String
_version: Int
}
without it we receive the following warning when attempting to update the resource. Note we will see the update locally but will receive an error from the GraphQL POST call
As a workaround, by manually adding an ID property to the model we can then push the schema and successfully update records which reflect in the AppSync console:
update the GraphQL schema
type Todo @model @auth(rules: [{ allow: owner }]) {
+ id: ID!
uid: String!
username: String
}
push the changes with amplify push -y
start the frontend dev server (Next.js in this example): yarn next
save record with JohnDoe
as the username
update record's username to JaneSmith
hello from the homepage
{todos?.length ? todos.map(todo => (
{JSON.stringify(todo, null, 2)}
))
: null}
Marking as a bug 🙂
@josefaidt thank you
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels for those types of questions.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication, DataStore, Storage
Amplify Categories
auth, storage, api
Environment information
Describe the bug
We are a small dev team that primarily worked with firebase. Recently we decided to implement a grapql based api and landed on giving amplify a shot.
The problem we faced is one that we have encountered many times in our search through the posted issues, seemingly having many faces but they boil down to local data not being persisted in DynamoDB. likely relating to app sync issues.
In our case what happens is the following, we have a Todo model that we create a new instance of using DataStore.save( new Todo ). This actually gets persisted to DynamoDB. However on further updates using DataStore.save and copyOf, the new data only persist locally which is expected but it never makes it to the DynamoDB, outboxMutationProcessed is never called. So naturally on sign out when we do DataStore.clear and then sign in again we get the data that was first persisted with DataStore.save( new Todo ) and not the updated version.
We have followed the relevant guides and setup the environment according to the docs, all packages are updated. Again the sync element works but only with the DataStore.save( new Todo ), but not when updating.
We have conflict resolution enabled and have tried both Auto Merge and Optimistic Concurrency.
It seems like the _.version, lastChangedAt, .updatedAt never changes and so it never syncs.
We hope you can help us resolve this issue as amplify seems like a wonderful product.
Expected behavior
We expect the data to persist to DynamoDB at some point whenever we make an update to one of the fields using copyOf.
Reproduction steps
Code Snippet
Log output
aws-exports.js
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