Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does API + Datastore play on the same project? #3005

Closed
lazy-var opened this issue Dec 16, 2019 · 6 comments
Closed

How does API + Datastore play on the same project? #3005

lazy-var opened this issue Dec 16, 2019 · 6 comments
Labels
question General question

Comments

@lazy-var
Copy link

lazy-var commented Dec 16, 2019

QUESTION
Which Category is your question related to?
API, Datastore.

Which Products is your question related to?
AppSync, AppSync's Conflict Detection , AppSync's Sync DynamoDB operation.

Hello,
This is an opinionated framework with 'ready to go' use cases, but I am using it because until now I could go custom as well, and I get tons of benefits from it.

I am amazed with Datastore announcement and such an early availability as it will solve plenty of developer needs when developing apps. Thank you very much!

I know it has just been released, and it is in preview, but already some doubts arise, and I couldn't find answers through the docs nor published videos. So here are my concerns:

  1. API + Datastore on the same project: I see them as separate tools that bring different added value –even if both are based on AppSync (GraphQL)–.
    I can easily find use cases with both tools running on the same app. After reading Model based APIs for API Category check against existence of DataStore amplify-swift#239 (comment) and Convert Amplify.API to protocol amplify-swift#249 (comment) I got concerned as it seems that you can not have a syncable datastore with a non syncable API at the same time. Will API and Datastore be able to play independent?, will them work at the same time? As far as I could test, when using both on the same project only one Appsync API is deployed to the backend. Which of the following alternatives should describe it better?:
    1. Should I consider API and Datastore two different Amplify independent categories with independent resources?: both API category and Datastore should deploy independent Appsync APIs (two schema).
    1. Should I consider API and Datastore two different Amplify categories that share same resources?: both API category and Datastore run independent (non-exclusive), but sharing the same Appsync API (one schema).
    1. Should I consider Datastore as an extension/feature for API?: so when Datastore is active, API should not be used. Then I would suggest evolving '@model' directive including options to choose on when using datastore/cloud-on-demand resources:
      ·@model-local models: current behavior achieved with datastore having "push" flag to false. This would be managed by 'Storage Engine' without 'Sync Engine'.
      ·@model-cloud models: current behavior achieved with API (without Datastore enabled). This would be managed by 'API' SDK and 'Apollo Cache'.
      ·@model-cloud-syncable models: current behavior achieved when activating Datastore. This would be managed by 'Storage Engine' + 'Sync Engine'.
  1. AppSync's Conflict Detection and AppSync's Sync DynamoDB operation are super Appsync features!🚀, but this time really opinionated 'ready to go' amplify flavored, and with a complete lack of customization😅. The Base table 'scan' part of it, plus the Delta DB indexing and queries doesn't fit my project needs 😅😅.
    1. In terms of Conflict Detection, as far as I understood it is done with the monotonic counter and the current version. Why is it needed the delta table on this?
    1. In terms of Sync operation, in order to get DeltaSync I believe I can use Datastore by overwriting Query.syncModelName.req.vtl with my own Sync resolver, using queries and my use case indexes instead of the new Sync operation. But I would love more information on how 'Sync Engine' works.

Thank you very much in advance.

@yuth yuth added DataStore question General question labels Dec 16, 2019
@lazy-var
Copy link
Author

I have opened two feature request regarding datastore models: local-only aws-amplify/amplify-category-api#358 and custom resources fed aws-amplify/amplify-category-api#357

@lazy-var
Copy link
Author

lazy-var commented Dec 19, 2019

I have just noticed the difference between working with API and Datastore at model registration time:

  • AWSDataStorePlugin(modelRegistration: AmplifyModels())
  • AWSAPIPlugin(modelRegistration: AmplifyModels())

Does that means that I could go with:

  • AWSDataStorePlugin(modelRegistration: AmplifyDatastoreModels())
  • AWSAPIPlugin(modelRegistration: AmplifyAPIModels())

so that Storage Engine, Storage Adapter, and Sync Engine only manage Datastore plugin registered models?
in addition, in parallel, can I independently work with API plugin registered models with backend fetching 'on demand'?

@lazy-var lazy-var changed the title API + Datastore How does API + Datastore plays on the same project? Dec 19, 2019
@lazy-var lazy-var changed the title How does API + Datastore plays on the same project? How does API + Datastore play on the same project? Dec 19, 2019
@yuth
Copy link
Contributor

yuth commented Dec 20, 2019

  1. API + Datastore on the same project: I see them as separate tools that bring different added value –even if both are based on AppSync (GraphQL)–.
    I can easily find use cases with both tools running on the same app. After reading aws-amplify/amplify-ios#239 (comment) and aws-amplify/amplify-ios#249 (comment) I got concerned as it seems that you can not have a syncable datastore with a non syncable API at the same time. Will API and Datastore be able to play independent?, will them work at the same time? As far as I could test, when using both on the same project only one Appsync API is deployed to the backend. Which of the following alternatives should describe it better?:

      1. Should I consider API and Datastore two different Amplify independent categories with independent resources?: both API category and Datastore should deploy independent Appsync APIs (two schema).
      1. Should I consider API and Datastore two different Amplify categories that share same resources?: both API category and Datastore run independent (non-exclusive), but sharing the same Appsync API (one schema).
      1. Should I consider Datastore as an extension/feature for API?: so when Datastore is active, API should not be used. Then I would suggest evolving '@model' directive including options to choose on when using datastore/cloud-on-demand resources:
        ·@model-local models: current behavior achieved with datastore having "push" flag to false. This would be managed by 'Storage Engine' without 'Sync Engine'.
        ·@model-cloud models: current behavior achieved with API (without Datastore enabled). This would be managed by 'API' SDK and 'Apollo Cache'.
        ·@model-cloud-syncable models: current behavior achieved when activating Datastore. This would be managed by 'Storage Engine' + 'Sync Engine'.

DataStore is an extension to the API category and the same resource will be used. DataStore is useful when you are building an app that needs support for offline data, where as using this with API category is useful to run it in a lambda (or some place where you know you won't be offline).

  1. AppSync's Conflict Detection and AppSync's Sync DynamoDB operation are super Appsync features!🚀, but this time really opinionated 'ready to go' amplify flavored, and with a complete lack of customization😅. The Base table 'scan' part of it, plus the Delta DB indexing and queries doesn't fit my project needs 😅😅.
    1. In terms of Conflict Detection, as far as I understood it is done with the monotonic counter and the current version. Why is it needed the delta table on this?

Delta Sync table is not used for conflict detection and resolution. But conflict detection works only when Delta Sync is enabled on the API, as the service does not expose a switch to turn on conflict detection separately

@efleurine
Copy link

hi @lazy-var so out of curiosity have you been able to successfully use both in the same project?

@ricobanga
Copy link

I'm pretty sure you can use both in the same project at the same time;

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question General question
Projects
None yet
Development

No branches or pull requests

4 participants