tiero - Fotolia

Tip

Access and modify data for mobile apps with AWS AppSync

Consider AWS AppSync to support mobile app development. Look into key features, such as real-time updates and in-app data querying, to determine if the service is right for your apps.

Mobile apps and cloud services can be a formidable pair, but they can be difficult to integrate.

Mobile app developers have expertise with common mobile SDKs and programming languages, but they're less familiar with the REST APIs needed to create a cloud back end. To address this challenge, AWS has built a suite of tools and mobile app services to simplify the use of the storage, authentication, serverless and search services required to make a modern mobile or web app.

Developers can use one of those tools, AWS AppSync, to address cloud data access and modification. AppSync is based on GraphQL and is designed for real-time and offline data queries, synchronization and communication. Here, we'll explain the basics of GraphQL, along with AppSync's features. We'll also briefly review AWS' portfolio of mobile app development products.

AppSync features and architecture

It's hard to dig into AppSync without first understanding GraphQL. The open source data query and manipulation language simplifies the creation of data services with simple REST APIs via a mechanism that defines data types, along with a query language and syntax. As the GraphQL tutorial illustrates, the JSON-like syntax is easy to master. To use an example from the tutorial, here's how you would use GraphQL to create a service to look up and return usernames:

type Query {
  me: User
}
 
type User {
  id: ID
  name: String
}

Add the following functions for each field on each type:

function Query_me(request) {
  return request.auth.user;
}
 
function User_name(user) {
  return user.getName();
}

After you deploy the GraphQL service above to a web or other back-end service, access and test it with code like this:

{
  me {
    name
  }
}
 
{
  "me": {
    "name": "Luke Skywalker"
  }
}

Now, let's turn to AWS AppSync, which provides an AWS-managed GraphQL service with additional features for mobile developers.

To start, create a GraphQL schema that defines an API on AWS Management Console. Then, deploy it as an AppSync service. AppSync handles the necessary compute and data resources -- or links to existing Amazon cloud services -- and connects them to the GraphQL API. Mobile or web apps can then query the API using GraphQL calls similar to our example above to access, modify and stream real-time data.

The following are the features that differentiate AppSync the most from basic GraphQL:

  • Real-time data access and updates via GraphQL "subscription" operations that provide live updates across clients and devices.
  • Offline data synchronization that enables apps to interact with and update data even when disconnected. AppSync does this through an offline programming model for asynchronous updates, with resynchronization when a device comes back online. Users can also customize how local data caches are updated under different network conditions.
  • In-app data querying, filtering and search of AWS data sources through built-in configurations. Developers can use GraphQL semantics to access AWS Lambda, Amazon DynamoDB and Amazon Elasticsearch. AppSync supports complicated queries, unstructured text search and various search operators.
  • Enterprise security and granular role-based access controls via AWS Identity and Access Management to set up users and define roles. Users can also secure access to AppSync APIs using API keys via AWS Key Management Service, a third-party OpenID provider or Amazon Cognito User Pools, which also support SAML (Security Assertion Markup Language) identity providers.

AppSync also has APIs and SDKs for popular mobile and web platforms. It uses the AWS Amplify Framework to integrate with iOS and Xcode; Android and Android Studio; and JavaScript, with support for popular frameworks, like Node.js and React.

Developers can also use AppSync to add GraphQL APIs to other AWS resources or arbitrary HTTP endpoints running on any web server instance.

AppSync use cases and getting started

AppSync is useful for any mobile app that requires access to online data, particularly applications that are ported to the most popular mobile platforms: iOS, Android and web browsers. Some notable cases include:

  • Collaboration apps that must coordinate content contributions from multiple users. AppSync can provide automatic updates of new posts and handle multiple data types through integrations with various Amazon cloud storage and database services.
  • Chat and social media apps where AppSync can manage the message flow, provide offline access to conversations and synchronize updates when the user reconnects.
  • Augmented reality and virtual reality training apps that require access to massive data sets and, in the case of AR, require real-time updates to reflect changing conditions.

AppSync in AWS' mobile app development ecosystem

AppSync is part of a larger ecosystem of Amazon cloud services that mobile developers can use to build composite apps that combine a mobile client with a cloud back end.

Popular services, such as Amazon S3, Lambda, DynamoDB, Cognito and an array of AI tools, play a role in mobile development, as do the other mobile-specific services:

  • Amplify: The aforementioned mobile development framework combines a JavaScript library, UI components and a command-line interface toolchain.
  • Device Farm: This enables mobile and web app testing on actual devices, not virtual simulations.
  • Pinpoint: This sends users targeted messages through email, voice or push notifications. Pinpoint can tailor communications by recording events from the client applications, such as session data and authentication data.
  • API Gateway: This API management service can handle REST and WebSocket application requests for back-end services. It automatically scales to accommodate different workloads.
  • AWS Mobile Hub: This provides a simple UI to wire together various AWS services with features such as user sign-in, push notifications, user data storage via DynamoDB, app content delivery, app analytics and prebuilt back-end cloud logic. It also has a conversational bot feature for text and voice chat.

Dig Deeper on AWS cloud development

App Architecture
Cloud Computing
Software Quality
ITOperations
Close