aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.43k stars 2.13k forks source link

Datastore saves data locally only #9895

Closed israx closed 2 years ago

israx commented 2 years ago

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

DataStore

Amplify Categories

api

Environment information

``` # Put output below this line System: OS: macOS 11.6.1 CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz Memory: 242.11 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 17.3.0 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.3.0 - /usr/local/bin/npm Browsers: Chrome: 101.0.4951.54 Firefox: 87.0 Safari: 14.1.2 npmPackages: @aws-amplify/ui-react: ^2.9.0 => 2.9.0 @aws-amplify/ui-react-internal: undefined () @aws-amplify/ui-react-legacy: undefined () @emotion/react: ^11.8.2 => 11.8.2 @emotion/styled: ^11.8.1 => 11.8.1 @fontsource/schoolbell: ^4.5.3 => 4.5.3 @mui/icons-material: ^5.5.0 => 5.5.0 @mui/material: ^5.5.0 => 5.5.0 @testing-library/jest-dom: ^5.16.2 => 5.16.2 @testing-library/react: ^12.1.4 => 12.1.4 @testing-library/user-event: ^13.5.0 => 13.5.0 @types/jest: ^27.4.1 => 27.4.1 @types/node: ^17.0.21 => 17.0.21 @types/react: ^17.0.40 => 17.0.40 @types/react-dom: ^17.0.13 => 17.0.13 aws-amplify: ^4.3.15 => 4.3.15 dotenv: ^16.0.0 => 16.0.0 (10.0.0) file-loader: ^6.2.0 => 6.2.0 material-ui-color: ^1.2.0 => 1.2.0 material-ui-image: ^3.3.2 => 3.3.2 react: ^17.0.2 => 17.0.2 react-color-palette: ^6.2.0 => 6.2.0 react-dom: ^17.0.2 => 17.0.2 react-material-ui-carousel: ^3.2.0 => 3.2.0 react-router-dom: ^6.2.2 => 6.2.2 react-scripts: 5.0.0 => 5.0.0 react-toastify: ^8.2.0 => 8.2.0 typescript: ^4.6.2 => 4.6.2 web-vitals: ^2.1.4 => 2.1.4 webpack: ^5.70.0 => 5.70.0 webpack-cli: ^4.9.2 => 4.9.2 npmGlobalPackages: @aws-amplify/cli: 8.0.2 @vue/cli: 4.5.12 corepack: 0.10.0 n: 8.0.1 nodemon: 2.0.15 npm-check-updates: 12.5.2 npm: 8.3.0 sass: 1.26.10 typescript: 4.4.4 yarn: 1.22.17 ```

Describe the bug

Amplify Datastore saves data locally only. When I use DataStore.save(), the data is not saved in dynamoDb . I'm able to query data that has being stored before though. Other than that, the App is listening for Datastore events and I never get a "ready" event. I'm wondering that the problem might be on the Schema design.

Here bellow I attached screenshots of my Schema design and where I'm listening for DataStore events.

Screen Shot 2022-05-11 at 11 56 23 AM

Screen Shot 2022-05-11 at 12 00 11 PM

Screen Shot 2022-05-11 at 12 00 20 PM

Expected behavior

DataStore being able to sync with dynamoDb

Reproduction steps

DataStore.Save(new Schema())

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

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

dpilch commented 2 years ago

Hi @israx, are you seeing this issue on DataStore.save for all models in your schema or a select few? Could you share some examples of the DataStore.save calls are showing this behavior?

israx commented 2 years ago

For all of them. This is how I'm calling the API and also here are some logged events I'm getting.

Screen Shot 2022-05-11 at 12 57 33 PM

Screen Shot 2022-05-11 at 1 12 33 PM

dpilch commented 2 years ago

Could you try upgrading to aws-amplify@4.3.21? This version contains a new feature that might show additional errors logged to the console.

pratikdhody commented 2 years ago

Hi,

I'm facing the same issue after running amplify pull into an existing React Native project. Using API.graphql saves data but DataStore.save submits data locally only and never syncs to cloud where as API.graphql(mutation) does. I've using version "aws-amplify": "^4.3.21"

Please advise @dpilch

dpilch commented 2 years ago

Hi @pratikdhody, are you seeing an error in the console?

israx commented 2 years ago

I was able to see the error logged in the console after updating aws-amplify, I was not passing an "id" property to one of my schemas. Now it's working fine.

dpilch commented 2 years ago

Do you mind sharing the full error message? We are working to improve the error logging and having real examples would be useful.

israx commented 2 years ago

Apologies I was not able to reproduce the error anymore. I already updated my schema design which is deployed to production.

github-actions[bot] commented 1 year ago

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 amplify-help forum.