Design production-grade GraphQL schemas with best practices and patterns
Design production-ready GraphQL schemas using industry-standard patterns like connections, payloads, and interfaces. Claude will use this when you need to create or refactor GraphQL APIs to ensure they're scalable and maintainable.
/plugin marketplace add pluginagentmarketplace/custom-plugin-graphql/plugin install developer-roadmap@pluginagentmarketplace-graphqlThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyArchitect scalable, maintainable GraphQL APIs
Learn industry-standard patterns for designing GraphQL schemas that scale. Covers naming conventions, pagination, error handling, and schema evolution.
| Pattern | When to Use | Example |
|---|---|---|
| Connection | Paginated lists | users: UserConnection! |
| Payload | Mutation results | CreateUserPayload |
| Input | Mutation args | CreateUserInput |
| Interface | Shared fields | interface Node { id: ID! } |
| Union | Multiple types | SearchResult = User | Post |
# Types: PascalCase
type User { }
type UserProfile { }
# Fields: camelCase
type User {
firstName: String!
lastName: String!
createdAt: DateTime!
isActive: Boolean! # Boolean prefix: is, has, can
}
# Queries: noun (singular/plural)
type Query {
user(id: ID!): User # Singular
users: UserConnection! # Plural
}
# Mutations: verb + noun
type Mutation {
createUser(input: CreateUserInput!): CreateUserPayload!
updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
deleteUser(id: ID!): DeleteUserPayload!
# Actions
sendEmail(input: SendEmailInput!): SendEmailPayload!
publishPost(id: ID!): PublishPostPayload!
}
# Inputs: [Action][Type]Input
input CreateUserInput { }
input UpdateUserInput { }
input UserFilterInput { }
# Payloads: [Action][Type]Payload
type CreateUserPayload { }
type UpdateUserPayload { }
# Connection pattern
type Query {
users(
first: Int
after: String
last: Int
before: String
filter: UserFilter
): UserConnection!
}
type UserConnection {
edges: [UserEdge!]!
pageInfo: PageInfo!
totalCount: Int!
}
type UserEdge {
node: User!
cursor: String!
}
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
# Usage
query GetUsers {
users(first: 10, after: "cursor123") {
edges {
node { id name }
cursor
}
pageInfo {
hasNextPage
endCursor
}
}
}
# Payload pattern (recommended)
type CreateUserPayload {
user: User
errors: [UserError!]!
}
type UserError {
field: String
message: String!
code: UserErrorCode!
}
enum UserErrorCode {
INVALID_EMAIL
DUPLICATE_EMAIL
WEAK_PASSWORD
NOT_FOUND
UNAUTHORIZED
}
# Union pattern (type-safe)
union CreateUserResult =
| CreateUserSuccess
| ValidationError
| NotAuthorizedError
type CreateUserSuccess {
user: User!
}
type ValidationError {
field: String!
message: String!
}
type NotAuthorizedError {
message: String!
}
type Mutation {
createUser(input: CreateUserInput!): CreateUserResult!
}
# Global object identification
interface Node {
id: ID!
}
type Query {
node(id: ID!): Node
nodes(ids: [ID!]!): [Node]!
}
type User implements Node {
id: ID!
name: String!
}
type Post implements Node {
id: ID!
title: String!
}
# Enables refetching any object by ID
query RefetchUser {
node(id: "User:123") {
... on User {
name
email
}
}
}
# schema.graphql (root)
type Query {
# User domain
user(id: ID!): User
users(filter: UserFilter): UserConnection!
# Product domain
product(id: ID!): Product
products(filter: ProductFilter): ProductConnection!
}
type Mutation {
# User mutations
createUser(input: CreateUserInput!): CreateUserPayload!
updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
# Product mutations
createProduct(input: CreateProductInput!): CreateProductPayload!
}
# types/user.graphql
type User implements Node {
id: ID!
email: String!
name: String!
createdAt: DateTime!
orders: OrderConnection!
}
# types/product.graphql
type Product implements Node {
id: ID!
name: String!
price: Money!
inventory: Int!
}
Returning a list?
├── Small fixed size (<20) → [Item!]!
└── Variable/large size → ItemConnection!
Mutation result?
├── Can have user errors → Payload pattern
└── System errors only → Direct return
Multiple possible types?
├── Completely different → Union
└── Share common fields → Interface
Nested data?
├── Always needed together → Embed
└── Sometimes needed → Separate + ID reference
type User {
# Always required
id: ID!
email: String!
# Optional (user choice)
nickname: String
bio: String
# Lists: require list, require items
posts: [Post!]! # Never null, items never null
# Computed (may fail)
avatar: String # Nullable if generation can fail
}
| Issue | Cause | Solution |
|---|---|---|
| Breaking change | Removed field | Use @deprecated first |
| Over-fetching | No pagination | Add Connection pattern |
| N+1 queries | Direct relations | Use DataLoader |
| Type explosion | Too many types | Use interfaces/generics |
# Validate
npx graphql-inspector validate schema.graphql
# Check breaking changes
npx graphql-inspector diff old.graphql new.graphql
# Coverage analysis
npx graphql-inspector coverage schema.graphql queries/*.graphql
Skill("graphql-schema-design")
graphql-fundamentals - Basic types and syntaxgraphql-resolvers - Implementing the schemagraphql-security - Auth-aware design02-graphql-schema - For detailed guidanceThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.