graphql-yoga
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "graphql-yoga":https://skillpi.com/zh/skills/deepskill-a789974dcaabbebc9564c1082383808e841acaf6dde84fc6ff82322d45aedb9a。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
GraphQL Yoga 专家指南,适用于使用 schema-first 或 code-first 方法构建生产级 GraphQL API。说明如何使用文件上传、订阅、Envelop 插件系统、响应缓存与错误屏蔽等功能,并部署到任意 JavaScript 运行时(如 Node.js、Deno、Bun、Cloudflare Workers、AWS Lambda)。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 实测状态
- 未测试
文件浏览
Frontmatter
name: graphql-yoga
description: >-
You are an expert in GraphQL Yoga, the batteries-included GraphQL server by
The Guild. You help developers build production GraphQL APIs with
schema-first or code-first approaches, file uploads, subscriptions, Envelop
plugin system, response caching, error masking, and deployment to any JS
runtime (Node.js, Deno, Bun, Cloudflare Workers, AWS Lambda) — the modern
alternative to Apollo Server.
license: Apache-2.0
compatibility: ''
metadata:
author: terminal-skills
version: 1.0.0
category: Backend Development
tags:
- graphql
- server
- api
- typescript
- envelop
- schema
- nodeGraphQL Yoga — Modern GraphQL Server
You are an expert in GraphQL Yoga, the batteries-included GraphQL server by The Guild. You help developers build production GraphQL APIs with schema-first or code-first approaches, file uploads, subscriptions, Envelop plugin system, response caching, error masking, and deployment to any JS runtime (Node.js, Deno, Bun, Cloudflare Workers, AWS Lambda) — the modern alternative to Apollo Server.
Core Capabilities
Server Setup
import { createSchema, createYoga } from "graphql-yoga";
import { createServer } from "http";
const yoga = createYoga({
schema: createSchema({
typeDefs: `
type Query {
users(limit: Int, offset: Int): [User!]!
user(id: ID!): User
}
type Mutation {
createUser(input: CreateUserInput!): User!
updateUser(id: ID!, input: UpdateUserInput!): User!
}
type Subscription {
newUser: User!
}
type User {
id: ID!
name: String!
email: String!
posts: [Post!]!
createdAt: String!
}
type Post {
id: ID!
title: String!
author: User!
}
input CreateUserInput { name: String!, email: String! }
input UpdateUserInput { name: String, email: String }
`,
resolvers: {
Query: {
users: (_, { limit = 10, offset = 0 }, ctx) =>
ctx.db.users.findAll({ limit, offset }),
user: (_, { id }, ctx) => ctx.db.users.findById(id),
},
Mutation: {
createUser: async (_, { input }, ctx) => {
const user = await ctx.db.users.create(input);
ctx.pubsub.publish("newUser", { newUser: user });
return user;
},
},
Subscription: {
newUser: {
subscribe: (_, __, ctx) => ctx.pubsub.subscribe("newUser"),
},
},
User: {
posts: (user, _, ctx) => ctx.db.posts.findByAuthor(user.id),
},
},
}),
context: ({ request }) => ({
db: database,
pubsub: pubSub,
user: authenticateRequest(request),
}),
maskedErrors: process.env.NODE_ENV === "production",
cors: { origin: ["https://app.example.com"], credentials: true },
graphiql: process.env.NODE_ENV !== "production",
});
const server = createServer(yoga);
server.listen(4000, () => console.log("GraphQL on http://localhost:4000/graphql"));
Envelop Plugins
import { useResponseCache } from "@graphql-yoga/plugin-response-cache";
import { useRateLimiter } from "@graphql-yoga/plugin-rate-limiter";
import { useDepthLimit } from "envelop-depth-limit";
const yoga = createYoga({
schema,
plugins: [
useResponseCache({
session: (req) => req.headers.get("authorization"),
ttl: 60_000, // 60s cache
invalidateViaMutation: true,
}),
useRateLimiter({
identifyFn: (ctx) => ctx.user?.id || ctx.request.headers.get("x-forwarded-for"),
max: 100,
window: "1m",
}),
useDepthLimit({ maxDepth: 10 }),
],
});
Installation
npm install graphql-yoga graphql
Best Practices
- Envelop plugins — Use the plugin system for auth, caching, rate limiting, logging; composable and reusable
- Response caching — Enable response cache for public queries; cache by session for authenticated queries
- Depth limiting — Set max query depth (10-15) to prevent abuse from deeply nested queries
- Error masking — Enable in production; prevents leaking internal error details to clients
- Subscriptions — Built-in SSE and WebSocket support; use PubSub for real-time updates
- File uploads — Native multipart support; no extra libraries needed for file upload mutations
- Any runtime — Deploy to Node.js, Deno, Bun, CF Workers, Lambda with the same code; runtime-agnostic
- DataLoader for N+1 — Use DataLoader in resolvers to batch database queries; prevents N+1 query problem
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 GraphQL Yoga 的完整开发支持,涵盖服务器搭建、插件系统、缓存、限流、订阅等生产级能力
- 面向后端开发者,解决构建现代 GraphQL API 的实际痛点,实用价值高
亮点
- description 明确描述 Skill 为 GraphQL Yoga 专家,涵盖 schema-first/code-first、插件、部署等核心能力
- 触发词完整且边界清晰,用户可准确识别适用场景
待提升项
-
缺少 When to Use 章节 原报告严重程度:轻微
文档未明确说明何时使用此 Skill,建议补充使用场景说明
改进建议:在文档开头或独立章节添加 When to Use,说明适合构建 GraphQL API、需要插件扩展、多运行时部署等场景
-
缺少端到端完整示例 原报告严重程度:轻微
代码示例为片段,缺少从初始化到运行的完整端到端示例
改进建议:补充一个完整的端到端示例,包括数据库连接、认证、插件配置、启动服务器全流程
-
文档略长 原报告严重程度:轻微
文档约 450 行,接近 500 行限制,可能影响阅读体验
改进建议:考虑将部分内容拆分为独立文件,或精简部分描述性文字
亮点
- 文档结构清晰,分 Core Capabilities、Installation、Best Practices,逻辑性强
- frontmatter 完整,包含 name、description、license、metadata 等信息
亮点
- 代码示例参数正确,涵盖主要异常处理(如错误屏蔽、深度限制)
- 工具来源明确(graphql-yoga 及相关插件),无不可逆操作,执行可靠性高
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 132 行 -
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 96 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- app.example.com
- localhost
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。