graphql-schema-design
БесплатноБез исполняемых скриптовНе проверенUse when designing GraphQL schemas with type system, SDL patterns, field design, pagination, directives, and versioning strategies for maintainable and…
от TheBushidoCollective★ 202 звезды на GitHubОб этом скилле
GraphQL Schema Design
Apply GraphQL schema design principles to create well-structured, maintainable, and scalable GraphQL APIs. This skill covers the type system, Schema Definition Language (SDL), field design patterns, pagination strategies, directives, and schema evolution techniques.
Core Type System
Object Types
Object types are the fundamental building blocks of GraphQL schemas. Each object type represents a kind of object you can fetch from your service, and what fields it has.
type User {
id: ID!
username: String!
email: String!
createdAt: DateTime!
posts: [Post!]!
profile: Profile
}
type Post {
id: ID!
title: String!
content: String!
author: User!
publishedAt: DateTime
tags: [String!]!
}
Interface Types
Interfaces define abstract types that multiple object types can implement. Use interfaces when multiple types share common fields.
interface Node {
id: ID!
createdAt: DateTime!
updatedAt: DateTime!
}
interface Timestamped {
createdAt: DateTime!
updatedAt: DateTime!
}
type Article implements Node & Timestamped {
id: ID!
createdAt: DateTime!
updatedAt: DateTime!
title: String!
content: String!
author: User!
}
type Comment implements Node & Timestamped {
id: ID!
createdAt: DateTime!
updatedAt: DateTime!
text: String!
author: User!
post: Post!
}
Union Types
Union types represent values that could be one of several object types. Use unions when a field can return different types without shared fields.
union SearchResult = Article | User | Tag | Comment
type Query {
search(query: String!): [SearchResult!]!
}
# Query example
query {
search(query: "graphql") {
__typename
... on Article {
title
content
}
... on User {
username
email
}
... on Tag {
name
count
}
}
}
Enum Types
Enums define a specific set of allowed values for a field. Use enums for fields with a fixed set of options to ensure type safety.
enum UserRole {
ADMIN
MODERATOR
USER
GUEST
}
enum PostStatus {
DRAFT
PUBLISHED
ARCHIVED
DELETED
}
enum SortOrder {
ASC
DESC
}
type User {
id: ID!
role: UserRole!
status: AccountStatus!
}
enum AccountStatus {
ACTIVE
SUSPENDED
DEACTIVATED
}
Input Types
Input types are used for complex arguments in queries and mutations. They allow you to pass structured data as a single argument.
input CreateUserInput {
username: String!
email: String!
password: String!
profile: UserProfileInput
}
input UserProfileInput {
firstName: String
lastName: String
bio: String
avatarUrl: String
}
input UpdatePostInput {
title: String
content: String
status: PostStatus
tags: [String!]
}
input PostFilterInput {
status: PostStatus
authorId: ID
tags: [String!]
createdAfter: DateTime
createdBefore: DateTime
}
type Mutation {
createUser(input: CreateUserInput!): User!
updatePost(id: ID!, input: UpdatePostInput!): Post!
}
type Query {
posts(filter: PostFilterInput, limit: Int): [Post!]!
}
Custom Scalars
Custom scalars extend the built-in scalar types (String, Int, Float, Boolean, ID) with domain-specific types.
scalar DateTime
scalar EmailAddress
scalar URL
scalar JSON
scalar UUID
scalar PositiveInt
scalar Currency
type User {
id: UUID!
email: EmailAddress!
website: URL
createdAt: DateTime!
metadata: JSON
age: PositiveInt
}
type Product {
id: ID!
price: Currency!
images: [URL!]!
}
Directives
Directives provide a way to modify execution behavior or add metadata to your schema.
# Built-in directives
type Query {
# Skip field if condition is true
user(id: ID!): User @skip(if: $skipUser)
# Include field only if condition is true
posts: [Post!]! @include(if: $includePosts)
}
type Post {
id: ID!
title: String!
# Mark field as deprecated with migration hint
oldTitle: String @deprecated(reason: "Use 'title' instead")
}
# Custom directives
directive @auth(requires: UserRole!) on FIELD_DEFINITION
directive @rateLimit(max: Int!, window: Int!) on FIELD_DEFINITION
directive @cacheControl(
maxAge: Int!
scope: CacheScope = PUBLIC
) on FIELD_DEFINITION | OBJECT
enum CacheScope {
PUBLIC
PRIVATE
}
type Query {
me: User @auth(requires: USER)
adminPanel: AdminData @auth(requires: ADMIN)
publicPosts: [Post!]!
@cacheControl(maxAge: 300)
@rateLimit(max: 100, window: 60)
}
Nullable vs Non-Null Design
Carefully consider nullability in your schema design. Non-null fields provide stronger guarantees but reduce flexibility.
type User {
# Required fields - will never be null
id: ID!
username: String!
email: String!
# Optional fields - may be null
bio: String
website: URL
# Non-null list with nullable items
# List itself will never be null, but items can be
favoriteColors: [String]!
# Nullable list wit
Установить graphql-schema-design в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл graphql-schema-design?
Use when designing GraphQL schemas with type system, SDL patterns, field design, pagination, directives, and versioning strategies for maintainable and scalable APIs.
Как установить скилл graphql-schema-design?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл graphql-schema-design запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic