Let’s have a look at the AppSync architecture. In the figure below we have depicted such a high-level solution architecture for an app, an AppSync API and AWS data sources. On the left-hand side we have the clients connecting to the API in the middle, and on the right-hand side, we have the data sources feeding the API.
An AppSync API is realized on the AppSync infrastructure, using GraphQL concepts, and it is secured using e.g. AWS Cognito. The API is defined by a GraphQL schema, consisting of types, queries, mutations, and subscriptions. The data of the API is delivered by any of the AWS data sources on the right: an Amazon DynamoDB, Amazon Elasticsearch or an AWS Lambda function. The raw data delivered by the data sources is transformed to GraphQL with a resolver.
AppSync clients (left side in the figure) use the GraphQL API. The clients interact with the API using the GraphQL query language. Learn more about creating AppSync clients and about writing GraphQL queries, mutations, and subscriptions in the AppSync Book.
GraphQL Server and Schema
AWS AppSync has a powerful GraphQL server (in the middle of the figure), which is used by all APIs on AppSync. Each API supports the definition of custom types and the three GraphQL methods: query (read-only), mutation (write), and subscription (event-based notification). Learn more about GraphQL schema and how it is used within AppSync in the AppSync Book.
The data served via a GraphQL API is usually in an existing database. AppSync offers a convenient way to connect databases from the AWS cloud:
- Amazon DynamoDB
- Amazon Elasticsearch
- Services deployed on AWS Lambda
Learn more about AppSync data sources in the AppSync Book.
Resolvers define a mapping from a GraphQL request to a data source request and from a data source response back to a GraphQL response. According to these two steps, the mapping consists of request mapping and a response mapping. Writing resolvers is the main software development activity when creating a GraphQL API. AppSync uses new concepts, a templating language and predefined templates to simplify resolver development. Learn more about AppSync resolver tooling in the AppSync Book.