ai-infrastructure-hugg…
Hugging Face Inference SDK patterns for TypeScript/Node.js — InferenceClient setup, chat completion, text generation, streaming, embeddings, image generation,…
URQL GraphQL client patterns — the exchange pipeline, document and normalized caching, queries, mutations, subscriptions, and authentication
$ npx -y skills add agents-inc/skills --skill web-data-fetching-graphql-urql --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/web-data-fetching-graphql-urqlContext preview
The summary Claude sees to decide when to auto-load this skill.
URQL GraphQL client patterns — the exchange pipeline, document and normalized caching, queries, mutations, subscriptions, and authentication
name: web-data-fetching-graphql-urql description: URQL GraphQL client patterns — the exchange pipeline, document and normalized caching, queries, mutations, subscriptions, and authentication
> **Quick Guide:** URQL is a small core plus a pipeline of exchanges, and almost every configuration > question is really a question about that pipeline's order — synchronous exchanges before > asynchronous ones, error handlers before what they catch, `fetchExchange` last. Caching is > document-based by default, keyed on the query and its variables; normalized caching is an opt-in > exchange. Hooks return a `[result, execute]` tuple, and the loading flag is `fetching`.
**Detailed Resources:**
---
cache entry, and a mutation invalidates every entry whose result shared a `__typename` with it. Nothing to configure, and no way to edit the cache by hand.
default one. Entities are stored once by key, so `keys`, `updates`, `resolvers` and `optimistic` become available and mutations can edit the cache precisely. Adds roughly 8KB.
Start with the document cache. Move to Graphcache when a mutation needs to change a list the server did not return, or when you want optimistic updates.
---
<critical_requirements>
**Order the exchanges: error handling, then synchronous, then asynchronous, with `fetchExchange` last.** An operation passes through them in array order, so a cache placed after a network exchange never sees a request, and an error handler placed after `authExchange` never sees a failed refresh.
**Put `__typename` in every optimistic response, along with every field a query reads.** Graphcache normalizes on `__typename` plus the key, and a field the optimistic object omits is a field the watching query cannot render.
**Set `preferGetMethod` to what the server accepts.** From v6 the client sends queries under 2048 characters as GET; `false` forces POST for everything, and `"force"` sends GET regardless of length.
</critical_requirements>
---
**Auto-detection:** `urql`, `@urql/core`, `@urql/exchange-graphcache`, `cacheExchange`, `fetchExchange`, `subscriptionExchange`, `mapExchange`, `ssrExchange`, `authExchange`, `retryExchange`, `useQuery`, `useMutation`, `useSubscription`, `requestPolicy`, `preferGetMethod`, `reexecuteQuery`, `CombinedError`, `wonka`
**Applies to:**
**Handled elsewhere:**
---
<philosophy>
The client itself does almost nothing: it turns a hook call into an operation and pushes it into a stream. Everything that looks like a feature — caching, auth, retries, deduplication, subscriptions, server rendering — is an exchange sitting in that stream, and every exchange sees the operation on the way out and the result on the way back.
Two things follow. Behaviour is added by installing an exchange rather than by configuring the client, so a project pays only for what it installs. And order is semantic rather than cosmetic: an exchange can only act on what has already reached it.
</philosophy>
---
<patterns>
import { Client, cacheExchange, fetchExchange } from "urql";
const client = new Client({
url: GRAPHQL_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
requestPolicy: "cache-first",
});`<Provider value={client}>` above the tree is what the hooks read; without it they throw at the first render rather than falling back to anything.
Full code: [examples/core.md](examples/core.md)
---
const [result, reexecuteQuery] = useQuery<UsersData, UsersVariables>({
query: USERS_QUERY,
variables: { limit: DEFAULT_PAGE_SIZE },
requestPolicy: "cache-and-network",
});
const { data, fetching, error, stale } = result;
if (fetching && !data) return <Skeleton />;
if (error && !data) return <Error message={error.message} />;`fetching` is true for the first load and for every background refresh, so `fetching && !data` is what distinguishes them. `stale` marks cached data being revalidated — an "updating" hint rather than a spinner. `pause: !userId` holds a query back until its variables are real.
Default policy is `cache-first`; `cache-and-network` is the stale-while-revalidate one. The full table is in [reference.md](reference.md).
Full code: [examples/core.md](examples/core.md)
---
const [result, executeMutation] = useMutation<CreatePostData>(CREATE_POST);
const response = await executeMutation({ input });
if (response.error) return;The execute function returns a promise c
The 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,…