urql
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "urql" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-534f562bcdbf71a0dd73098fa9f16a96bba0cf3d6056ac1c77934ea5a9e4cb98. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
urql expert assistance. urql is a highly customizable, lightweight GraphQL client for React, Vue, Svelte, and plain JavaScript. Helps fetch GraphQL data with minimal bundle size, supports document caching, normalized caching via Graphcache, exchanger (middleware) pipelines, subscriptions, and offline support, serving as a leaner and more extensible alternative to Apollo Client.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Testing
- Not tested
Browse files
Frontmatter
name: urql
description: >-
You are an expert in urql, the highly customizable and lightweight GraphQL
client for React, Vue, Svelte, and vanilla JavaScript. You help developers
fetch GraphQL data with minimal bundle size, document caching, normalized
caching via Graphcache, exchanges (middleware pipeline), subscriptions, and
offline support — providing a leaner alternative to Apollo Client with
better extensibility.
license: Apache-2.0
compatibility: ''
metadata:
author: terminal-skills
version: 1.0.0
category: Frontend Development
tags:
- graphql
- react
- client
- lightweight
- cache
- exchange
- typescripturql — Lightweight GraphQL Client
You are an expert in urql, the highly customizable and lightweight GraphQL client for React, Vue, Svelte, and vanilla JavaScript. You help developers fetch GraphQL data with minimal bundle size, document caching, normalized caching via Graphcache, exchanges (middleware pipeline), subscriptions, and offline support — providing a leaner alternative to Apollo Client with better extensibility.
Core Capabilities
Setup and Queries
import { Client, Provider, cacheExchange, fetchExchange, gql, useQuery, useMutation } from "urql";
const client = new Client({
url: "https://api.example.com/graphql",
exchanges: [cacheExchange, fetchExchange],
fetchOptions: () => ({
headers: { Authorization: `Bearer ${getToken()}` },
}),
});
function App() {
return <Provider value={client}><Dashboard /></Provider>;
}
const POSTS_QUERY = gql`
query Posts($limit: Int!) {
posts(limit: $limit) { id title author { name } createdAt }
}
`;
function PostList() {
const [result, reexecute] = useQuery({
query: POSTS_QUERY,
variables: { limit: 10 },
});
const { data, fetching, error } = result;
if (fetching) return <Spinner />;
if (error) return <Error message={error.message} />;
return (
<div>
{data.posts.map(p => <PostCard key={p.id} post={p} />)}
<button onClick={() => reexecute({ requestPolicy: "network-only" })}>Refresh</button>
</div>
);
}
Mutations
const CREATE_POST = gql`
mutation CreatePost($input: CreatePostInput!) {
createPost(input: $input) { id title createdAt }
}
`;
function CreatePostForm() {
const [result, createPost] = useMutation(CREATE_POST);
const handleSubmit = (data: any) => {
createPost({ input: data }).then(result => {
if (result.error) console.error(result.error);
});
};
return <Form onSubmit={handleSubmit} loading={result.fetching} />;
}
Graphcache (Normalized Cache)
import { cacheExchange } from "@urql/exchange-graphcache";
const cache = cacheExchange({
keys: { Post: (data) => data.id as string },
resolvers: {
Query: {
post: (_, args) => ({ __typename: "Post", id: args.id }),
},
},
updates: {
Mutation: {
createPost(result, _args, cache) {
cache.updateQuery({ query: POSTS_QUERY, variables: { limit: 10 } }, (data) => {
if (data) data.posts.unshift(result.createPost);
return data;
});
},
},
},
});
Installation
npm install urql graphql
npm install @urql/exchange-graphcache # Optional normalized cache
Best Practices
- Document cache — Default cache deduplicates by query+variables; sufficient for most apps
- Graphcache for complex — Use normalized cache only when you need cache updates across queries
- Exchanges — urql's middleware pipeline; add auth, retry, persist, logging as composable exchanges
- Request policies — Use
cache-first(default),network-onlyfor refresh,cache-and-networkfor stale-while-revalidate - Bundle size — urql core is ~5KB gzipped (vs Apollo ~30KB); ideal for performance-sensitive apps
- SSR support — Use
ssrExchangefor server-side rendering; hydrates cache on client - Subscriptions — Add
subscriptionExchangefor WebSocket/SSE subscriptions; plug and play - Framework agnostic — Works with React, Vue, Svelte, and vanilla JS; same core, different bindings
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- urql 是前端 GraphQL 开发的高频刚需工具,文档覆盖核心能力与最佳实践
- 提供轻量级替代 Apollo Client 的明确价值主张,适合性能敏感场景
Highlights
- 触发词精准覆盖 urql 核心概念:cache、exchange、Graphcache、subscriptions
- description 位置正确且内容完整,边界清晰无歧义
Areas to improve
-
缺少 When to Use 显式章节 Reported severity: Minor
文档未设置独立的 When to Use 章节说明适用场景
Recommendation: 建议添加 When to Use 章节,明确说明何时选择 urql 而非其他 GraphQL 客户端
Highlights
- 结构清晰:Setup → Queries → Mutations → Graphcache → Installation → Best Practices
- 提供完整端到端代码示例,frontmatter 元数据完整规范
Highlights
- 工具来源明确(urql 官方包),参数配置正确
- 覆盖主要异常状态(fetching/error),mutation 有错误处理机制
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 123, 124
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- api.example.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.