awslabs / aws-mobile-appsync-sdk-android

Android SDK for AWS AppSync.
https://docs.amplify.aws/sdk/api/graphql/q/platform/android/
Apache License 2.0
105 stars 58 forks source link

How is this different from the Apollo Android client? #303

Closed manideepla closed 4 years ago

manideepla commented 4 years ago

I know there exists the Apollo client to consume a GraphQL API. But what does this SDK do in addition to the Apollo client? Are there exact features of this SDK listed somewhere?

jamesonwilliams commented 4 years ago

Hi manideepl@, the team at AWS created this code base to quickly onboard functionalities that did not exist in the upstream project at that time, in support of AppSync's launch.

The original commits entered this repository as copy-paste of the Apollo codebase, discarding the upstream git history. Based on heuristic info, I believe the fork occurred from the master branch of Apollo, somewhere before the 0.5.0 release, which occurred on 17 April, 2018. For reference, AppSync became generally available four days before that, on April 13, 2018.

AppSync Specific Features

This client supports a number of AppSync-specific features which are not part of the GraphQL specification, and are not included in the Apollo client. (Note: as evidenced by the above timeline, the AppSync service was written against the 2015-2016 specs, not the later 2018 spec, which came out several weeks later.) The SDK documentation mentions these AppSync-specific functionalities, among others:

  1. AWS request signing, including Sig V4, and support for various AWS-specific authentication and authorization strategies (IAM, Cognito User Pools, etc.)

  2. Delta and base sync queries, which aim to optimize data consumption from a mobile device.

  3. GraphQL subscriptions via AppSync Realtime

  4. DynamoDB/S3 hybrid-backed "Complex Objects"

  5. Code-generation for all of the various AppSync transforms.

Using Vanilla Apollo

Let's fast-forward to mid-2020. The Apollo open source project is the de-facto standard for transacting with GraphQL endpoints. The Android client repository is a healthy, actively-developed open-source project, seeing a new commit nearly every day. At time of writing, the latest release is 2.2.3, significantly ahead of where the AppSync SDK originated. In some cases (viz, here), we have needed to back-port important fixes from the upstream codebase.

As an exercise, I recently tried communicating with AppSync using a recent version of Apollo Android, 2.2.0. See Hitting AWS AppSync from Apollo Android 2.2.0. The most immediately visible gaps are around AWS request signing and authentication, and around support for subscriptions.

Amplify DataStore

With the exception of a few features, like Complex Objects, the Amplify DataStore is a newer data management option, which may be a suitable replacement to the AppSync SDK for many customers. Some will find the local data management interface more intuitive than this SDK's interface. The Amplify DataStore handles all of the complexities of speaking GraphQL to AppSync on behalf of the user.

Current Status (3 Aug 2020)

We are currently supporting the AWS AppSync SDK for Android. Customers are encouraged to evaluate the Amplify DataStore, but may use the AppSync SDK if the DataStore does not meet your project requirements.