ai-infrastructure-hugg…
Hugging Face Inference SDK patterns for TypeScript/Node.js — InferenceClient setup, chat completion, text generation, streaming,…
GraphQL API server with Apollo Server — schema, resolvers, context, error handling, data sources, plugins
Claude Code
$ npx -y skills add agents-inc/skills --skill api-graphql-apollo-server --agent claude-code
Codex
$ npx skills add agents-inc/skills --skill api-graphql-apollo-server -a codex -y
Cursor
$ npx skills add agents-inc/skills --skill api-graphql-apollo-server -a cursor -y
Gemini CLI
$ npx skills add agents-inc/skills --skill api-graphql-apollo-server -a gemini-cli -y
GitHub Copilot
$ npx skills add agents-inc/skills --skill api-graphql-apollo-server -a github-copilot -y
OpenCode
$ npx skills add agents-inc/skills --skill api-graphql-apollo-server -a opencode -y
Windsurf
$ npx skills add agents-inc/skills --skill api-graphql-apollo-server -a windsurf -y
name: api-graphql-apollo-server description: GraphQL API server with Apollo Server — schema, resolvers, context, error handling, data sources, plugins
> **Quick Guide:** Use `@apollo/server` (v5) for schema-first GraphQL APIs. Define schemas with SDL (`typeDefs`), implement field population with resolvers, share per-request state via the `context` function, and handle errors with `GraphQLError` + extension codes. Use `startStandaloneServer` for quick setups or integrate with your HTTP framework for production. DataLoader solves the N+1 problem. Plugins hook into the request lifecycle for logging, auth, and performance.
---
<critical_requirements>
**(You MUST import from `@apollo/server` -- NOT the deprecated `apollo-server` or `apollo-server-express` packages)**
**(You MUST create new data source and DataLoader instances per request in the context function -- sharing across requests causes data leaks)**
**(You MUST throw `GraphQLError` (from `graphql`) with extension codes for client-facing errors -- generic `Error` exposes stack traces)**
**(You MUST use `ApolloServerPluginDrainHttpServer` when integrating with an HTTP framework -- without it the server doesn't shut down gracefully)**
</critical_requirements>
---
**Auto-detection:** Apollo Server, @apollo/server, ApolloServer, startStandaloneServer, expressMiddleware, GraphQLError, typeDefs, resolvers, contextValue, DataLoader, RESTDataSource, @apollo/datasource-rest, ApolloServerPlugin, buildSubgraphSchema, @apollo/subgraph, graphql-ws, PubSub, formatError, gql tag
**When to use:**
**When NOT to use:**
**Key patterns covered:**
**Detailed Resources:**
---
<philosophy>
Apollo Server follows a **schema-first** approach: define your API contract in SDL, then implement resolvers to populate each field. The schema is the single source of truth for your API shape, documentation, and type system.
**Core principles:**
1. **Schema as contract** -- SDL defines what clients can query before implementation begins 2. **Thin resolvers** -- Resolvers orchestrate data fetching but delegate to data sources and services 3. **Per-request context** -- Each operation gets fresh data source instances and auth state via the context function 4. **Graceful error handling** -- `GraphQLError` with extension codes communicates errors without leaking internals
**Use Apollo Server when:**
**Use simpler approaches when:**
</philosophy>
---
<patterns>
Two approaches: `startStandaloneServer` for quick/simple setups, or framework middleware integration for production.
import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
const server = new ApolloServer({ typeDefs, resolvers });
const DEFAULT_PORT = 4000;
const { url } = await startStandaloneServer(server, {
context: async ({ req }) => ({
token: req.headers.authorization,
}),
listen: { port: DEFAULT_PORT },
});**Why good:** minimal boilerplate for development, context function provides per-request auth state
For production with an HTTP framework, use `expressMiddleware` (from `@as-integrations/express4` or `@as-integrations/express5`) with `ApolloServerPluginDrainHttpServer` for graceful shutdown.
See [examples/core.md](examples/core.md) for both setup patterns with full TypeScript types.
---
Resolvers receive four arguments: `parent` (return value from parent resolver), `args` (field arguments), `contextValue` (shared per-request state), and `info` (operation metadata).
const resolvers = {
Query: {
user: async (_parent, args, contextValue) => {
return contextValue.dataSources.usersAPI.The official skills marketplace for Agents Inc. 230+ skills covering everything from React and Prisma to Redis, ElevenLabs, and infrastructure tooling. Pick the skills that match your stack and install them via Claude Code. Need more control?
Hugging Face Inference SDK patterns for TypeScript/Node.js — InferenceClient setup, chat completion, text generation, streaming,…
LiteLLM proxy server setup, TypeScript client patterns via OpenAI SDK, model routing, fallbacks, load balancing, spend tracking,…
Serverless GPU compute platform for AI model deployment — web endpoints, GPU functions, model serving, and TypeScript client…
Local LLM inference with the Ollama JavaScript client -- chat, streaming, tool calling, vision, embeddings, structured output,…
Replicate SDK patterns for TypeScript/Node.js -- client setup, predictions, streaming, webhooks, file handling, model versioning,…
Together AI SDK patterns for TypeScript — client setup, chat completions, streaming, structured output, function calling,…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.