Design & UI v1.0.0

graphql-schema

Deep GraphQL schema workflow—modeling types, queries and mutations, N+1 and complexity limits, errors and pagination,...

codenova58 更新于 2026-03-25 1 浏览
下载 SKILL

技能说明

Deep GraphQL schema workflow—modeling types, queries and mutations, N+1 and complexity limits, errors and pagination, federation risks, and evolution. Use when designing or reviewing GraphQL APIs.

使用场景

GraphQL concentrates complexity on the server: resolver graphs, N+1 fetches, schema evolution, and field-level authorization.

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

帮我下载并安装这个SKILL:https://skillhub.cstcloud.cn/download/graphql-schema
  1. 点击上方「下载 SKILL」按钮,获取技能压缩包。
  2. 将压缩包解压到你的 Agent 技能目录。
  3. 重启客户端后即可在技能列表中选择该技能。

技能文件内容

4 个文件 · 15 kB
SKILL.md text/markdown
---
name: graphql-schema
description: Deep GraphQL schema workflow—modeling types, queries and mutations, N+1 and complexity limits, errors and pagination, federation risks, and evolution. Use when designing or reviewing GraphQL APIs.
---

# GraphQL Schema (Deep Workflow)

GraphQL concentrates complexity on the server: **resolver graphs**, **N+1** fetches, **schema evolution**, and **field-level authorization**.

## When to Offer This Workflow

**Trigger conditions:**

- Designing a new GraphQL API or federated subgraph
- Latency or complexity incidents from client queries
- Need for safe schema deprecation and versioning

**Initial offer:**

Use **six stages**: (1) domain modeling, (2) operations surface, (3) performance patterns, (4) errors & partial results, (5) security & authz, (6) versioning & evolution). Confirm client patterns (Apollo, Relay) and gateway (if any).

---

## Stage 1: Domain Modeling

**Goal:** Types reflect domain concepts; avoid dumping everything on `Query`; use input objects for mutations with validation.

---

## Stage 2: Operations Surface

**Goal:** Queries for reads; mutations for writes; subscriptions only when justified (scaling and operational cost).

### Pagination

- Prefer cursor-based connections for large lists (Relay-style edges/nodes)

---

## Stage 3: Performance Patterns

**Goal:** DataLoader or batching for N+1; query complexity/depth/cost limits; optional persisted queries for public APIs.

---

## Stage 4: Errors & Partial Results

**Goal:** Document semantics of `errors` alongside partial `data`; map domain failures to structured extensions.

---

## Stage 5: Security & Authz

**Goal:** Enforce authorization at field/object level—not only at the top resolver.

---

## Stage 6: Versioning & Evolution

**Goal:** Prefer additive changes; `@deprecated` with migration window; in federation, clear ownership of types and entities.

---

## Final Review Checklist

- [ ] Schema reflects domain and operations
- [ ] Pagination and mutations idiomatic
- [ ] Batching and complexity limits in place
- [ ] Error behavior documented for clients
- [ ] Field-level authz enforced
- [ ] Deprecation policy defined

## Tips for Effective Guidance

- N+1 is the default failure mode—plan batching early.
- Pair with **rest-best-practices** when REST and GraphQL coexist at the edge.

## Handling Deviations

- Public APIs: consider persisted queries or allowlists to limit abusive queries.

文件内容直接读取自技能仓库,仅供安装前审阅;以实际下载的压缩包为准。