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.44k stars 2.13k forks source link

How to seed certain data into appsync backed tables ? #10207

Open BBopanna opened 2 years ago

BBopanna commented 2 years ago

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

GraphQL API

Amplify Categories

auth, storage, api, hosting

Environment information

``` # Put output below this line System: OS: macOS 12.4 CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz Memory: 259.82 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.15.1 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.15.0 - /usr/local/bin/npm Browsers: Chrome: 104.0.5112.79 Safari: 15.5 npmGlobalPackages: @aws-amplify/cli: 8.5.1 corepack: 0.10.0 npm: 8.15.0 typescript: 4.7.4 yarn: 1.22.19 npm notice npm notice New minor version of npm available! 8.15.0 -> 8.17.0 npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.17.0 npm notice Run npm install -g npm@8.17.0 to update! npm notice ```

Describe the bug

We have a requirement that when we add a new amplify env we want certain data also known as seedData to be present in certains tables.

Example : Zipcode model backed table should have certain data when a new env is created or added - How can we achieve this without explicitly a cognito user creating it?

We could like for this data to be available for every new amplify env added begining with the dev env that amplify init creates

How can this be achieved ?

Expected behavior

Be able to seed default data into appsync model backed tables.

Reproduction steps

NA

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

chrisbonifacio commented 2 years ago

Hi @BBopanna 👋 thanks for raising this issue. Unfortunately, this is not currently supported or available as a feature. The only seeding capabilities we currently offer are via Amplify Studio. However, this does not automatically happen on new environment creation and requires that DataStore be enabled on the GraphQL API. Unless you have offline data requirements, that may not be what you want or need.

For more information on that: https://docs.amplify.aws/console/tutorial/data/#create-data-model

I have labeled this as a feature request and made the data team aware of it for future consideration.