AppSync is a managed GraphQL API service. Instead of REST endpoints, clients query exactly what data they need. Real-time subscriptions built-in.
Real-World: A React app needs user profile + their recent orders + order items. With REST: 3 API calls. With GraphQL/AppSync: 1 query returns exactly what's needed.
query {
user(id: "123") {
name
email
orders(limit: 5) {
id
total
items {
name
price
}
}
}
}AppSync resolvers connect to data sources:
| Data Source | Example |
|---|---|
| DynamoDB | User profiles, product catalog |
| Lambda | Complex business logic, external APIs |
| RDS (Aurora Serverless) | Relational data |
| HTTP | REST APIs, third-party services |
| ElasticSearch/OpenSearch | Full-text search |
| None | Local resolvers, static responses |
subscription OnOrderUpdate {
onUpdateOrder(customerId: "cust_123") {
id
status
updatedAt
}
}Client subscribes via WebSocket → when DynamoDB item updates → AppSync pushes to subscribed clients.
Real-World: Order tracking page updates automatically when order status changes.
AppSync has server-side caching:
- Cache entire API responses or per-resolver
- TTL configurable
- Reduce calls to DynamoDB/Lambda
type Query {
getMyOrders: [Order] @aws_cognito_user_pools # Only authenticated users
getPublicProducts: [Product] # Anyone
}AppSync validates Cognito JWT automatically.
- AppSync = GraphQL + Real-time subscriptions. REST API = API Gateway.
- AppSync + DynamoDB: direct integration without Lambda for simple CRUD.
- Real-time = subscriptions via WebSocket. API Gateway also has WebSocket — but AppSync is managed and GraphQL-specific.
- AppSync Offline: via Amplify DataStore — synchronizes local data when connection restored.
Amplify is a full-stack development platform — CLI, libraries, and hosting for web/mobile apps. It provisions AWS services automatically.
amplify add auth→ provisions Cognito User Poolamplify add api→ provisions AppSync or API Gatewayamplify add storage→ provisions S3amplify hosting→ CloudFront + S3 static hostingamplify add predictions→ Rekognition, Polly, Translate
Real-World: Mobile developer runs amplify init → amplify add auth → amplify add api → amplify push → entire backend created. Frontend library connects everything.
Offline-first data sync:
import { DataStore } from 'aws-amplify';
import { Order } from './models';
// Works offline, syncs to AppSync/DynamoDB when online
const orders = await DataStore.query(Order, o => o.status('eq', 'PENDING'));- Amplify is the full-stack framework (CLI + libraries). AppSync is the managed GraphQL service.
- Amplify Hosting = CI/CD + hosting for frontend apps (like Vercel/Netlify but on AWS).
- For exam: if question mentions "mobile app + offline sync" → Amplify DataStore + AppSync.