@klonguski/aws-movie-api
v0.1.1
Published
Headless TypeScript client for CRUD against my AWS AppSync movie-list GraphQL API
Readme
@klonguski/aws-movie-api
Headless TypeScript client for CRUD against my AWS AppSync movie-list GraphQL API. Ships ESM + CJS with full type definitions. Node ≥ 18.
Install
npm install @klonguski/aws-movie-apiConfigure
The client needs the AppSync endpoint and API key, via env vars or explicit options:
| Env var | Option | Notes |
| --- | --- | --- |
| MOVIE_API_URL | url | AppSync GraphQL endpoint |
| MOVIE_API_KEY | apiKey | AppSync API key |
| MOVIE_API_TIMEOUT_MS | timeoutMs | Request timeout, default 10000 |
Usage
import { createClient } from "@klonguski/aws-movie-api";
const client = createClient(); // reads env vars
// or: createClient({ url: "...", apiKey: "..." })
const movies = await client.listMovies();
const movie = await client.getMovie("some-id"); // undefined if not found
const created = await client.createMovie({
title: "Arrival",
director: "Denis Villeneuve",
year: 2016,
});
await client.updateMovie(created.id, { year: 2017 });
await client.deleteMovie(created.id);
// Escape hatch for arbitrary GraphQL:
const data = await client.raw<{ listMovies: unknown }>("query { listMovies { items { id } } }");Errors from the API throw MovieApiError, which carries the underlying GraphQL errors.
License
MIT
