aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.32k stars 246 forks source link

Any plans for supporting advanced GraphQL functionality outside the Datastore Plugin? #1129

Open Dachmian opened 2 years ago

Dachmian commented 2 years ago

In native applications or javascript it is possible to utilize the low-level SDK to get access to features such as:

Are there any plans to support this kind of functionality for the API plugin and not only DataStore? To use DataStore you have to go "all in" in using AWS Amplify as a way to setup the backend and go all in with offline functionality. For us, and I expect many others, it is unacceptable to use AWS Amplify in this way as we currently developing applications that go way beyond the app<->appsync<->dynamodb use case that AWS Amplify offers you. We are using CDK for our backend provisioning and the experienc has been great. Offline functionality is also not something we can have for many of our projects.

To make our experience much better would be to offer the three functionalities I listed at the start as we now have to make workaround and refetch data and parsing mutation responses into the ui instead of everything going through the queries.

Thanks!

dnys1 commented 2 years ago

Hi @Dachmian - can you provide some examples of code you would like to see ported to Flutter? The features you mention seem very specific to DataStore and I would like to gather more info about where we can improve its usability.

DataStore supports the observeQuery API in Flutter now which seems to address the query watcher and delta sync issue. Being able to turn on/off the cloud-sync functionality is also available with the start/stop methods. We are always working to bring Amplify Flutter to feature parity with the other platforms, so your input will help greatly in helping us see where we fall short.

Dachmian commented 2 years ago

Hi @dnys1

Thank you for the quick response.

The code I am referring to can be seen for example here: https://docs.amplify.aws/lib/graphqlapi/offline/q/platform/js/ Where you can use the low level Amplify SDK to do the things I mentioned above.

I know DataStore support the observeQuery API and supports a very nice api to work with data just as working with local data only. The problem we have is that in order to use DataStore, you have to provision the backend using AWS Amplify framework and the CLI and you have to support offline for all your data. Currently we cannot use AWS Amplify to provision the backend due to multiple reasons and we therefore use CDK for this. Based on the popularity that CDK has I also suspect many others do this.

We basically really like AWS Amplify for the Client side libraries and we use API, Auth and Storage plugins, but the backend is set up with CDK. So question is how we can have all the nice features of DataStore but without offline functionality (basically require mutations to be issued against appsync immediately) and with using CDK for provisioning?

dnys1 commented 2 years ago

To your first point, you're correct that Amplify Flutter does not provide so-called "escape hatch" functionality like the JS and native SDKs do. This is unfortunately not something we're likely to support in the near future due to the complexity involved with exposing those lower level APIs. At some point, we expect to have a lot of that functionality ported to pure Dart, which will make this use case much easier. Although, this may not be for a long while.

And to your second point, it is unfortunately very difficult to setup DataStore outside of the CLI. I believe there is ongoing work to improve integration with the CDK, such as the recently released export functionality. This is an area I see a lot of requests for and I believe we will continue to see work being done there.

I'm sorry that I don't have more positive answers to your questions. I'm happy to leave this open as a feature request ticket and I think over time we will get closer to resolving these issues, but it may take several months.

Dachmian commented 2 years ago

@dnys1

I understand. Thank you for the provided information. I also think we should leave this as a feature request ticket and for information to other people that might look for the same things.

We have looked at blogs and information showing how DataStore can be integrated outside of the CLI and it seems it is possible to achieve, although no ideal way to do it at the moment. Interfaces and Unions also seem to be a headache in this process as well.

I guess that a way to integrate DataStore Client outside the CLI and a way to disable offline mutations ( or force immediate sync ) seems like the shortest way to victory here.

Thanks!