npx skills add https://github.com/apollographql/skills --skill graphql-schema本指南涵盖了设计直观、高性能且易于维护的 GraphQL 模式的最佳实践。模式设计主要是服务器端关注的问题,直接影响 API 的可用性。
"""
A user in the system.
"""
type User {
id: ID!
email: String!
name: String
posts(first: Int = 10, after: String): PostConnection!
createdAt: DateTime!
}
| 模式 | 含义 |
|---|---|
| String | 可为空 - 可能为 null |
| String! | 非空 - 始终有值 |
| [String] |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 可为空列表,可为空项 |
| [String!] | 可为空列表,非空项 |
| [String]! | 非空列表,可为空项 |
| [String!]! | 非空列表,非空项 |
最佳实践: 对于列表使用 [Type!]! 模式 - 空列表优于 null,且无 null 项。
# 输出类型 - 客户端接收的内容
type User {
id: ID!
email: String!
createdAt: DateTime!
}
# 输入类型 - 客户端发送的内容
input CreateUserInput {
email: String!
name: String
}
# 使用输入类型的变更操作
type Mutation {
createUser(input: CreateUserInput!): User!
}
interface Node {
id: ID!
}
type User implements Node {
id: ID!
email: String!
}
type Post implements Node {
id: ID!
title: String!
}
union SearchResult = User | Post | Comment
type Query {
search(query: String!): [SearchResult!]!
}
特定主题的详细文档:
mutation(input: InputType!)Node 接口ID 类型作为标识符,而非 String 或 Int每周安装量
767
代码仓库
GitHub 星标数
36
首次出现
2026 年 1 月 23 日
安全审计
安装于
opencode623
codex615
claude-code608
gemini-cli599
github-copilot598
kimi-cli531
This guide covers best practices for designing GraphQL schemas that are intuitive, performant, and maintainable. Schema design is primarily a server-side concern that directly impacts API usability.
"""
A user in the system.
"""
type User {
id: ID!
email: String!
name: String
posts(first: Int = 10, after: String): PostConnection!
createdAt: DateTime!
}
| Pattern | Meaning |
|---|---|
| String | Nullable - may be null |
| String! | Non-null - always has value |
| [String] | Nullable list, nullable items |
| [String!] | Nullable list, non-null items |
| [String]! | Non-null list, nullable items |
| [String!]! | Non-null list, non-null items |
Best Practice: Use [Type!]! for lists - empty list over null, no null items.
# Output type - what clients receive
type User {
id: ID!
email: String!
createdAt: DateTime!
}
# Input type - what clients send
input CreateUserInput {
email: String!
name: String
}
# Mutation using input type
type Mutation {
createUser(input: CreateUserInput!): User!
}
interface Node {
id: ID!
}
type User implements Node {
id: ID!
email: String!
}
type Post implements Node {
id: ID!
title: String!
}
union SearchResult = User | Post | Comment
type Query {
search(query: String!): [SearchResult!]!
}
Detailed documentation for specific topics:
mutation(input: InputType!)Node interface for refetchabilityID type for identifiers, not String or IntWeekly Installs
767
Repository
GitHub Stars
36
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode623
codex615
claude-code608
gemini-cli599
github-copilot598
kimi-cli531
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
Grimoire CLI 使用指南:区块链法术编写、验证与执行全流程
940 周安装
Grimoire Uniswap 技能:查询 Uniswap 元数据与生成代币/资金池快照的 CLI 工具
940 周安装
Grimoire Aave 技能:查询 Aave V3 元数据和储备快照的 CLI 工具
941 周安装
Railway CLI 部署指南:使用 railway up 命令快速部署代码到 Railway 平台
942 周安装
n8n Python 代码节点使用指南:在自动化工作流中编写 Python 脚本
943 周安装
Flutter Platform Views 实现指南:Android/iOS/macOS原生视图与Web嵌入教程
943 周安装