aws-appsync-js
A tiny, fully-typed, zero-dependency GraphQL client for AWS AppSync.
Plain fetch under the hood, end-to-end TypeScript inference on top, ~3Β KB gzipped.
The whole API, basically
import { AppSyncClient } from 'aws-appsync-js';
const client = new AppSyncClient({
url: 'https://xxx.appsync-api.us-east-1.amazonaws.com/graphql',
auth: { type: 'apiKey', apiKey: 'da2-β¦' },
});
const { events } = await client.request<{ events: Event[] }>(`
query { events { id name } }
`);
Two lines of setup, one line per query, and the response is typed exactly the way you say it is. The rest of these docs are "and alsoβ¦".
Why this existsβ
The AppSync ecosystem has two extremes:
aws-amplifyβ full SDK, ~200Β KB minified, expects you to live inside its world.- Hand-rolled
fetch+ SigV4 + auth-mode plumbing β three subtle things to get right, per service.
aws-appsync-js is the missing middle: a tiny GraphQL-over-fetch client that:
- Understands AppSync β every auth mode, retry semantics, the JSON error shape AppSync actually uses.
- Speaks real TypeScript β not
any-flavoured types. Discriminated auth unions,TypedDocumentNodeinference, typed error classes. - Doesn't drag in anything else β zero runtime dependencies. SigV4 written from scratch on
node:crypto/SubtleCrypto. - Works everywhere β Node β₯ 18.17, modern browsers, Cloudflare Workers, Vercel Edge, Deno, Bun.
At a glanceβ
What's insideβ
| Capability | Status |
|---|---|
| All 5 AppSync auth modes | β |
| TypedDocumentNode inference | β |
| AbortSignal + per-request timeouts | β |
| Retries with exponential backoff + jitter | β |
Typed error classes with stable code | β |
| Introspection helper | β |
Custom fetch injection | β |
| Subscriptions (WebSocket / MQTT-over-WS) | π§ planned |
| Client-side cache / normalisation | β by design β bring your own (TanStack Query, SWR, Zustand, β¦) |
Next stepsβ
- Quickstart β install + first query in 60 seconds.
- Auth modes β pick the right one and get it typed correctly.
- TypeScript & codegen β make the compiler write your types for you.
- Cookbook β timeouts, retries, partial data, observability.
- API reference β full TypeDoc output.