4.2.2. AWS AppSync for GraphQL APIs
First Principle: AWS AppSync simplifies building scalable GraphQL APIs that abstract data sources, enabling developers to query and update data efficiently across multiple backend services with a single API endpoint.
AppSync hosts GraphQL APIs that let clients request exactly the data they need, connecting to DynamoDB, Lambda, and HTTP backends through resolvers. GraphQL is a query language for APIs that allows clients to request exactly the data they need, no more and no less, reducing over-fetching and under-fetching.
- Managed GraphQL API: AppSync handles the provisioning and management of the GraphQL server.
- Real-time Data: Supports real-time data updates via subscriptions (WebSockets), enabling live application features.
- Offline Data Synchronization: Provides client-side libraries that enable applications to work offline and synchronize data when connectivity is restored.
- Multiple Data Sources: Integrates directly with various AWS data sources:
- Amazon DynamoDB: For NoSQL data.
- AWS Lambda: For custom logic to access any data source.
- Amazon Aurora: For relational data.
- Amazon Elasticsearch Service: For search.
- HTTP endpoints: For existing APIs.
- Authentication & Authorization: Integrates with Amazon Cognito User Pools, IAM, and API keys.
Scenario: You need to build a new mobile application that requires a flexible API to fetch and update data from multiple backend sources (DynamoDB, Lambda). Clients should be able to request specific data fields to reduce network overhead, and some features require real-time data updates.
ā ļø Exam Trap: AppSync uses GraphQL, not REST. If a question asks about a single endpoint that lets clients request exactly the data they need (no over-fetching), AppSync is the answer. For traditional REST APIs, use API Gateway.
