ai-infrastructure-hugg…
Hugging Face Inference SDK patterns for TypeScript/Node.js — InferenceClient setup, chat completion, text generation, streaming, embeddings, image generation,…
Apollo Client GraphQL patterns — normalized cache and type policies, queries, mutations with optimistic updates, pagination, fragments, subscriptions, and Suspense hooks
$ npx -y skills add agents-inc/skills --skill web-data-fetching-graphql-apollo --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/web-data-fetching-graphql-apolloContext preview
The summary Claude sees to decide when to auto-load this skill.
Apollo Client GraphQL patterns — normalized cache and type policies, queries, mutations with optimistic updates, pagination, fragments, subscriptions, and Suspense hooks
name: web-data-fetching-graphql-apollo description: Apollo Client GraphQL patterns — normalized cache and type policies, queries, mutations with optimistic updates, pagination, fragments, subscriptions, and Suspense hooks
> **Quick Guide:** Apollo stores every entity once, keyed by `__typename` plus its `keyFields`, and > re-renders everything watching it. Most of the difficulty is in the cache rather than the hooks: > `keyFields` decides identity, `keyArgs` decides how many cache entries a paginated field gets, and > an optimistic response missing `__typename` fails to normalize without saying so. v3.9 added the > Suspense hooks; v4 moved the React hooks to `@apollo/client/react` and typed the error classes.
**Detailed Resources:**
---
`new HttpLink()`, `uri` on the client is gone, and errors are `CombinedGraphQLErrors` / `ServerError` rather than one `ApolloError`. The full map is in [reference.md](reference.md); `npx @apollo/client-codemod-migrate-3-to-4` does the mechanical part.
the nearest error boundary. Pattern 9, then [examples/suspense.md](examples/suspense.md).
each state itself. Patterns 2 onward.
---
<critical_requirements>
**Generate the operation types from the schema.** A hand-written response type is a second copy of the schema that nothing keeps in step, and it goes wrong silently — the field the backend added is absent from the type and absent from every render that needed it.
**Put `__typename` and the identifying field in every optimistic response.** Without them the entry cannot be normalized, so the optimistic write lands nowhere and the UI does not move until the server answers.
**Give every entity type a `keyFields` policy.** It is what decides whether two responses are the same entity, and the default `["id"]` is wrong for anything keyed on `sku`, a slug, or a pair.
</critical_requirements>
---
**Auto-detection:** `ApolloClient`, `InMemoryCache`, `ApolloProvider`, `useQuery`, `useLazyQuery`, `useMutation`, `useSubscription`, `useFragment`, `useSuspenseQuery`, `useLoadableQuery`, `useBackgroundQuery`, `useReadQuery`, `createQueryPreloader`, `typePolicies`, `keyFields`, `keyArgs`, `cache.modify`, `cache.evict`, `relayStylePagination`, `makeVar`, `gql`
**Applies to:**
**Handled elsewhere:**
cases here, and anything derived or complex belongs to whatever owns client state
---
<philosophy>
The cache is the product. A response is not stored as a response — it is split into entities keyed by `__typename` plus `keyFields`, and every hook watching one of those entities re-renders when it changes. So one mutation updates every list, detail view and badge showing that entity, without any of them refetching.
The corollary is that everything which can go wrong with Apollo is an identity question: two responses that should have been one entry, one entry that should have been two, or a write the cache could not place because it did not know what it was.
</philosophy>
---
<patterns>
Build the cache with a type policy per entity, and compose the link chain so auth and error handling sit in front of the transport.
const cache = new InMemoryCache({
typePolicies: {
User: { keyFields: ["id"] },
Product: { keyFields: ["sku"] }, // identity is not always "id"
CartItem: { keyFields: false }, // embed in the parent, never its own entry
Query: { fields: { usersConnection: relayStylePagination(["filter"]) } },
},
});`keyFields` takes `["id"]`, another single field, a composite like `["authorId", "postId"]`, `[]` for a singleton, or `false` to embed.
Full code: [examples/core.md](examples/core.md) — codegen config, auth link, error link, client singleton
---
const { data, loading, error, refetch } = useQuery<GetUsersQuery, GetUsersQueryVariables>(
GET_USERS,
{ variables: { limit: DEFAULT_PAGE_SIZE }, fetchPolicy: "cache-and-networThe official skills marketplace for Agents Inc. 150+ 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?
Repo: agents-inc/skills
Hugging Face Inference SDK patterns for TypeScript/Node.js — InferenceClient setup, chat completion, text generation, streaming, embeddings, image generation,…
LiteLLM proxy server setup, TypeScript client patterns via OpenAI SDK, model routing, fallbacks, load balancing, spend tracking, virtual keys, and production…
Serverless GPU compute platform for AI model deployment — web endpoints, GPU functions, model serving, and TypeScript client patterns
Local LLM inference with the Ollama JavaScript client -- chat, streaming, tool calling, vision, embeddings, structured output, model management, and…
Replicate SDK patterns for TypeScript/Node.js -- client setup, predictions, streaming, webhooks, file handling, model versioning, deployments, and training
Together AI SDK patterns for TypeScript — client setup, chat completions, streaming, structured output, function calling, embeddings, image generation,…