graphql-expert · personamanagmentlayer — скилл для Claude Code: GraphQL API
Скилл graphql-expert помогает проектировать GraphQL-схемы, писать резолверы и разбирать подписки. Пригодится при работе с Apollo Server, федерацией и проблемой N+1.
Apache-2.0 169 установок ★ 45 обновлён 2026-10-12
npx skills add personamanagmentlayer/pcl --skill graphql-expert -a claude-codeЧто делает graphql-expert
Скилл подсказывает, как организовать типы, интерфейсы, входные данные и резолверы GraphQL. Он охватывает запросы и мутации, пагинацию, фильтрацию, обработку ошибок и подписки через WebSocket. Для федерации описаны подграфы и шлюз Apollo.
В рекомендациях есть DataLoader для борьбы с N+1, ограничение глубины и сложности запросов, кэширование и тестирование через Vitest. Скилл также разбирает авторизацию, GraphQL Codegen и Apollo Client. Для примеров с Apollo Server 4 и DataLoader он даёт отдельные справочные материалы; это подсказки по разработке, а не готовый сервер. Для установки нужен npx.
Какие задачи решает
- спроектировать типы и структуру GraphQL-схемы
- написать резолверы для запросов и мутаций
- связать подграфы через федерацию Apollo
- снизить количество запросов при проблеме N+1
- добавить пагинацию и ограничить глубину запросов
Примеры запросов агенту
- Спроектируй GraphQL-схему для пользователей и публикаций с типами и мутациями.
- Проверь резолверы и предложи, как устранить проблему N+1 через DataLoader.
- Настрой федерацию Apollo для сервисов пользователей и публикаций.
Как установить graphql-expert
1Через Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill graphql-expert -a claude-code2Вручную: положить файлы
~/.claude/skills/graphql-expert/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/graphql-expert/
1Через Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill graphql-expert -a codex2Вручную: положить файлы
.agents/skills/graphql-expert/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill graphql-expert -a cursor2Вручную: положить файлы
.cursor/skills/graphql-expert/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install personamanagmentlayer/pcl stdlib/api/graphql-expert2Вручную: положить файлы
.github/skills/graphql-expert/SKILL.md1Через Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill graphql-expert -a gemini-cli2Командой платформы
gemini skills install https://github.com/personamanagmentlayer/pcl --path stdlib/api/graphql-expertВручную: положить файлы
.devin/skills/graphql-expert/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill graphql-expert -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о graphql-expert
Как установить graphql-expert в Claude Code?
Выполните npx skills add personamanagmentlayer/pcl --skill graphql-expert -a claude-code. Файл скилла находится по пути ~/.claude/skills/graphql-expert/SKILL.md.
Что делает graphql-expert?
Помогает разрабатывать GraphQL API: проектировать схемы, писать резолверы и настраивать подписки. Также рассматривает федерацию Apollo, пагинацию и оптимизацию запросов.
Как скилл помогает при проблеме N+1?
Он рекомендует применять DataLoader, а также описывает пакетную загрузку и устранение дублирующих запросов.
Исходный текст
SKILL.md · Apache-2.0
---
name: graphql-expert
version: 1.1.0
description: >-
Expert-level GraphQL API development with schema design, resolvers, and subscriptions.
Use when the user mentions API, apollo, schema, resolvers, subscriptions, or relay, or
when the task involves Schema Design, Queries and Mutations, Apollo Server 4, or
DataLoader for N+1 Prevention.
category: api
tags: [graphql, api, apollo, schema, resolvers, subscriptions, relay]
allowed-tools:
- Read
- Write
- Edit
- Bash(node:*, npm:*, npx:*)
---
# GraphQL Expert
Expert guidance for GraphQL API development, schema design, resolvers, subscriptions, and best practices for building type-safe, efficient APIs.
## Core Concepts
### Schema Design
- Type system and schema definition language (SDL)
- Object types, interfaces, unions, and enums
- Input types and custom scalars
- Schema stitching and federation
- Modular schema organization
### Resolvers
- Resolver functions and data sources
- Context and info arguments
- Field-level resolvers
- Resolver chains and data loaders
- Error handling in resolvers
### Queries and Mutations
- Query design and naming conventions
- Mutation patterns and best practices
- Input validation and sanitization
- Pagination strategies (cursor-based, offset)
- Filtering and sorting
### Subscriptions
- Real-time updates with WebSocket
- Subscription resolvers
- PubSub patterns
- Subscription filtering
- Connection management
### Performance
- N+1 query problem and DataLoader
- Query complexity analysis
- Depth limiting and query cost
- Caching strategies (field-level, full response)
- Batching and deduplication
## GraphQL Federation
### Federated Schema
```typescript
// Users service
import { buildSubgraphSchema } from '@apollo/subgraph';
const typeDefs = gql`
extend schema @link(url: "https://specs.apollo.dev/federation/v2.3")
type User @key(fields: "id") {
id: ID!
email: String!
name: String!
}
type Query {
user(id: ID!): User
users: [User!]!
}
`;
const resolvers = {
User: {
__resolveReference: async (reference, { dataSources }) => {
return dataSources.userAPI.getUserById(reference.id);
},
},
Query: {
user: (_, { id }, { dataSources }) => dataSources.userAPI.getUserById(id),
users: (_, __, { dataSources }) => dataSources.userAPI.getUsers(),
},
};
// Posts service
const typeDefs = gql`
extend schema @link(url: "https://specs.apollo.dev/federation/v2.3")
type Post @key(fields: "id") {
id: ID!
title: String!
content: String!
author: User!
}
extend type User @key(fields: "id") {
id: ID! @external
posts: [Post!]!
}
type Query {
post(id: ID!): Post
posts: [Post!]!
}
`;
const resolvers = {
Post: {
author: (post) => ({ __typename: 'User', id: post.authorId }),
},
User: {
posts: (user, _, { dataSources }) =>
dataSources.postAPI.getPostsByAuthorId(user.id),
},
};
// Gateway
import { ApolloGateway, IntrospectAndCompose } from '@apollo/gateway';
const gateway = new ApolloGateway({
supergraphSdl: new IntrospectAndCompose({
subgraphs: [
{ name: 'users', url: 'http://localhost:4001/graphql' },
{ name: 'posts', url: 'http://localhost:4002/graphql' },
],
}),
});
const server = new ApolloServer({ gateway });
```
## Anti-Patterns to Avoid
❌ **Exposing internal IDs**: Use opaque IDs or UUIDs
❌ **Overly nested queries**: Limit query depth
❌ **No pagination**: Always paginate lists
❌ **Resolving in mutations**: Keep mutations focused
❌ **Exposing database schema directly**: Design API-first
❌ **No DataLoader**: Leads to N+1 queries
❌ **Generic error messages**: Provide actionable errors
❌ **No versioning strategy**: Plan for schema evolution
## Testing
```typescript
import { ApolloServer } from '@apollo/server';
import { describe, it, expect } from 'vitest';
describe('GraphQL Server', () => {
it('should fetch user by id', async () => {
const server = new ApolloServer({ typeDefs, resolvers });
const response = await server.executeOperation({
query: `
query GetUser($id: ID!) {
user(id: $id) {
id
name
email
}
}
`,
variables: { id: '1' },
});
expect(response.body.kind).toBe('single');
expect(response.body.singleResult.data?.user).toEqual({
id: '1',
name: 'Alice',
email: '[email protected]',
});
});
it('should create post', async () => {
const response = await server.executeOperation({
query: `
mutation CreatePost($input: CreatePostInput!) {
createPost(input: $input) {
id
title
}
}
`,
variables: {
input: {
title: 'Test Post',
content: 'Content',
},
},
});
expect(response.body.singleResult.data?.createPost).toHaveProperty('id');
});
});
```
## Reference Documentation
Detailed material lives alongside this skill and is read on demand:
- [Common Patterns](references/PATTERNS.md) — Relay Cursor Pagination, File Upload
- [Best Practices](references/BEST_PRACTICES.md) — Schema Design, Performance Optimization, Security
- [Modern GraphQL Development](references/MODERN_GRAPHQL_DEVELOPMENT.md) — Apollo Server 4, DataLoader for N+1 Prevention, GraphQL Codegen, Error Handling, Authentication & Authorization, Subscriptions with WebSocket, GraphQL Client (Apollo Client), Query Complexity & Depth Limiting
## Resources
- Apollo Server: https://www.apollographql.com/docs/apollo-server/
- GraphQL Spec: https://spec.graphql.org/
- DataLoader: https://github.com/graphql/dataloader
- GraphQL Code Generator: https://the-guild.dev/graphql/codegen
- GraphQL Tools: https://the-guild.dev/graphql/tools
© personamanagmentlayer · Apache-2.0 · personamanagmentlayer/pcl
Похожие скиллы
Все скиллы по теме «Бэкенд и API» →Сначала — graphql-expert от других авторов.