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

DataStore Sync Response rather than full record #9959

Open sacrampton opened 2 years ago

sacrampton commented 2 years ago

Is this related to a new or existing framework?

React Native

Is this related to a new or existing API?

DataStore

Is this related to another service?

No response

Describe the feature you'd like to request

The repository for all of our data is DynamoDB, which as a No-SQL database which is a really efficient way to store data. For a particular Model (Asset) we have ~400 attributes defined, but we only need to store attributes that actually exist in DynamoDB - but we have the flexibility to store more as required by our process.

On the mobile app we only need a fraction of these attributes so ideally we could specify a GraphQL response and only the fields in the GraphQL response is sent to DataStore.

image

For example, I have ~400 attributes on an Asset record, but I might only want 4 attributes on the mobile app and can specify that in the GraphQL response.

query datastore {
  syncAssets(
    filter: { assetPlantId: { eq: "4ffcfbf6-xxxx-46f1-yyyy-dbd1967a2d06" } }
    limit: 500
  ) {
    items {
      id
      name
      shortDescription
      _version
    }
  }
}

However, to get DataStore working with adequate performance we need to use SQLite - a relational database. So we have no alternative but to download all ~400 attributes - most with NULL values - down to DataStore on the mobile app. This results in a massive database mostly taken up with NULL values because it ignores any GraphQL response and sends all attributes - even if NULL - to SQLite.

Describe the solution you'd like

Being able to specify a GraphQL response and having ONLY the fields detailed in the GraphQL response sent to the DataStore SQLite repository.

Describe alternatives you've considered

Don't know any alternative

Additional context

No response

Is this something that you'd be interested in working on?

sacrampton commented 2 years ago

Just checking if there is any response on this issue?

iartemiev commented 2 years ago

Hi @sacrampton, we've raised this with our Product Managers and will consider it as a future enhancement. Just to set expectations, this will probably not be prioritized this year due to us having many features in the back log already.