AWS AppSync, GraphQL and AWS Amplify for Developers: Resolvers, Subscriptions, Hosting and Full-Stack Apps

AWS Developer Associate 45 min min read Updated: Nov 17, 2026 Intermediate
AWS AppSync, GraphQL and AWS Amplify for Developers: Resolvers, Subscriptions, Hosting and Full-Stack Apps
Intermediate Topic 3 of 3

GraphQL in One Minute

GraphQL lets the client ask for exactly the fields it needs in one request to one endpoint, instead of calling many REST endpoints and getting extra data.

graphql type Task { id: ID! title: String! done: Boolean! owner: String } type Query { getTask(id: ID!): Task listTasks(limit: Int, nextToken: String): TaskConnection } type TaskConnection { items: [Task], nextToken: String } type Mutation { createTask(title: String!): Task completeTask(id: ID!): Task } type Subscription { onCreateTask: Task @aws_subscribe(mutations: ["createTask"]) }
graphql query { listTasks(limit: 10) { items { id title done } } }
OperationMeaning
QueryRead data
MutationChange data
SubscriptionReal-time updates pushed to clients over WebSockets when a mutation happens

What AppSync Is

AWS AppSync is a managed GraphQL (and Pub/Sub) service. You provide a schema, attach data sources, and write resolvers that map each field to a data source. AppSync handles scaling, WebSocket subscriptions, caching and security.

PartMeaning
SchemaTypes, queries, mutations, subscriptions
Data sourcesDynamoDB, Lambda, HTTP endpoints, OpenSearch, Aurora (Data API), EventBridge, RDS, and NONE (local resolvers)
ResolversCode that turns a GraphQL field request into a data source request and shapes the response. JavaScript resolvers (APPSYNC_JS) are the current approach; older VTL mapping templates still exist
Pipeline resolversRun several functions in sequence (for example check permissions, then read data)
Merged APIs and Events APICombine several APIs. Newer WebSocket pub/sub options (check docs)
javascript // JavaScript resolver for Mutation.createTask with a DynamoDB data source import { util } from "@aws-appsync/utils"; export function request(ctx) { const id = util.autoId(); return { operation: "PutItem", key: util.dynamodb.toMapValues({ id }), attributeValues: util.dynamodb.toMapValues({ title: ctx.args.title, done: false, owner: ctx.identity.sub, createdAt: util.time.nowISO8601(), }), condition: { expression: "attribute_not_exists(id)" }, }; } export function response(ctx) { if (ctx.error) util.error(ctx.error.message, ctx.error.type); return ctx.result; }

Authorization Modes

ModeUse
API keyPublic or prototype access. Keys expire (up to 365 days)
Cognito user poolsSigned-in users and groups, with directives such as @aws_auth(cognito_groups: ["admins"]) or @aws_cognito_user_pools
IAMBackend services and identity pool guests
OIDCThird-party identity providers
Lambda authorizerCustom logic
  • You can enable multiple modes: one default plus additional modes per type or field using directives
  • Filter data by owner in resolvers using ctx.identity.sub so users only see their own items

Subscriptions and Real Time

  • Clients subscribe and AppSync pushes results when the linked mutation runs. Good for chat, dashboards, collaboration, live scores
  • Use subscription filters so clients get only relevant events
  • Subscriptions work only for changes made through AppSync mutations. For changes done elsewhere publish with a mutation (for example from a Lambda function)

Performance

  • Server-side caching (per-API or per-resolver) with a TTL
  • Batch resolvers (BatchGetItem) to avoid the N+1 problem
  • Use DataLoader-style batching on Lambda resolvers
  • Delta sync for offline-capable mobile apps

REST (API Gateway) vs GraphQL (AppSync)

API Gateway REST/HTTPAppSync GraphQL
StyleMany resource endpointsOne endpoint, client-chosen fields
Real timeWebSocket API (build routes)Built-in subscriptions
Best forSimple CRUD APIs, partner APIs, public REST contractsRich client apps with varied data needs, mobile, real-time
Data accessMostly via Lambda or integrationsDirect DynamoDB resolvers without Lambda

AWS Amplify

Amplify is a set of tools to build and host full-stack web and mobile apps quickly.

PartWhat it does
Amplify HostingGit-connected CI/CD and hosting (CloudFront + S3 style) for React, Next.js, Vue, Angular and more. Preview environments per pull request, custom domains, SSR support
Amplify Gen 2 (code-first backend)Define backend (auth, data, storage, functions) in TypeScript, deployed with CDK under the hood. Per-developer cloud sandboxes
Amplify librariesJavaScript, Swift, Android and Flutter libraries for Auth (Cognito), Storage (S3), API (AppSync/REST), analytics, push
Amplify UIPrebuilt components such as the Authenticator
typescript // amplify/data/resource.ts (Amplify Gen 2 style) import { a, defineData, type ClientSchema } from "@aws-amplify/backend"; const schema = a.schema({ Task: a.model({ title: a.string().required(), done: a.boolean().default(false) }) .authorization((allow) => [allow.owner()]), }); export type Schema = ClientSchema<typeof schema>; export const data = defineData({ schema, authorizationModes: { defaultAuthorizationMode: "userPool" } });
javascript import { generateClient } from "aws-amplify/data"; const client = generateClient(); await client.models.Task.create({ title: "Learn AppSync" }); const { data: tasks } = await client.models.Task.list(); client.models.Task.onCreate().subscribe({ next: (t) => console.log("new", t) });
Check current docs Amplify changes quickly between generations (Gen 1 CLI and Gen 2). Always follow the current Amplify documentation for exact commands.

Practice Tasks

  1. Create an AppSync API with a DynamoDB data source and test queries in the console
  2. Write a JavaScript resolver that stores ctx.identity.sub as the owner
  3. Open two browser tabs and watch a subscription deliver a new item
  4. Protect a mutation to the admins Cognito group
  5. Deploy a React app with Amplify Hosting from a Git repository

Conclusion

GraphQL lets clients request exactly the data they need. AppSync provides the managed GraphQL API with resolvers to DynamoDB, Lambda and HTTP sources, multiple authorization modes, caching and real-time subscriptions. Amplify adds hosting, a code-first backend and client libraries for faster full-stack delivery.

Quick Summary: GraphQL; AppSync parts; resolver; auth modes; subscriptions; performance; REST vs GraphQL; Amplify.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators