graphql
БесплатноБез исполняемых скриптовНе проверенBuild and consume GraphQL APIs. Use when a user asks to create a GraphQL server, write GraphQL schemas, implement resolvers, set up subscriptions, build a…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
GraphQL
Overview
Design, build, and consume GraphQL APIs. This skill covers schema-first and code-first approaches, resolver patterns, real-time subscriptions, authentication, performance optimization with DataLoader, pagination, federation for microservices, and client-side consumption with Apollo Client.
Instructions
Step 1: Project Setup
Server (Apollo Server):
npm install @apollo/server graphql@16 # Apollo Server 5 needs graphql 16.11+ (not 17)
npm install express cors @as-integrations/express4 # Express 5: @as-integrations/express5
npm install dataloader graphql-subscriptions # N+1 batching, PubSub
npm install graphql-ws ws @graphql-tools/schema # subscriptions over WebSocket
Apollo Server 5 no longer ships @apollo/server/express4; expressMiddleware now comes from the separate @as-integrations/express4 package. Without Express, startStandaloneServer from @apollo/server/standalone is enough.
Client (Apollo Client):
npm install @apollo/client graphql rxjs
Apollo Client 4 imports React hooks from @apollo/client/react and no longer builds an HTTP link from the uri option.
Type generation:
npm install -D @graphql-codegen/cli @graphql-codegen/typescript @graphql-codegen/typescript-resolvers # then: npx graphql-codegen init
Step 2: Schema Design
type Query {
user(id: ID!): User
users(filter: UserFilter, pagination: PaginationInput): UserConnection!
feed(cursor: String, limit: Int = 20): PostConnection!
}
type Mutation {
createUser(input: CreateUserInput!): User!
updateUser(id: ID!, input: UpdateUserInput!): User!
createPost(input: CreatePostInput!): Post!
likePost(id: ID!): Post!
}
type Subscription {
postCreated: Post!
}
type User {
id: ID!
email: String!
name: String!
posts(limit: Int = 10): [Post!]!
createdAt: DateTime!
}
type Post {
id: ID!
title: String!
content: String!
author: User!
comments: [Comment!]!
likes: Int!
createdAt: DateTime!
}
# Relay-style cursor pagination
type UserConnection {
edges: [UserEdge!]!
pageInfo: PageInfo!
totalCount: Int!
}
type UserEdge { node: User!; cursor: String! }
type PageInfo { hasNextPage: Boolean!; hasPreviousPage: Boolean!; endCursor: String }
input CreateUserInput { email: String!; name: String! }
input UpdateUserInput { name: String; avatar: String }
input CreatePostInput { title: String!; content: String!; tags: [String!] }
input PaginationInput { first: Int; after: String }
scalar DateTime
Schema design rules: use ! for non-nullable fields, input types for mutations, Relay-style connections for pagination, descriptive verb names (createUser, not addUser).
Step 3: Resolvers
import { GraphQLError } from 'graphql';
export const resolvers = {
Query: {
user: async (_, { id }, { dataSources }) => dataSources.users.getById(id),
users: async (_, { filter, pagination }, { dataSources }) => {
const { first = 20, after } = pagination || {};
const result = await dataSources.users.getMany({ filter, first, after });
return {
edges: result.items.map(item => ({
node: item, cursor: Buffer.from(item.id).toString('base64'),
})),
pageInfo: { hasNextPage: result.hasMore, hasPreviousPage: !!after,
endCursor: result.items.at(-1) ? Buffer.from(result.items.at(-1).id).toString('base64') : null },
totalCount: result.totalCount,
};
},
},
Mutation: {
createUser: async (_, { input }, { dataSources, user }) => {
if (!user) throw new GraphQLError('Not authenticated', { extensions: { code: 'UNAUTHENTICATED' } });
return dataSources.users.create(input);
},
createPost: async (_, { input }, { dataSources, user }) => {
if (!user) throw new GraphQLError('Not authenticated', { extensions: { code: 'UNAUTHENTICATED' } });
return dataSources.posts.create({ ...input, authorId: user.id });
},
},
User: { posts: async (parent, { limit }, { dataSources }) => dataSources.posts.getByAuthor(parent.id, limit) },
Post: { author: async (parent, _, { dataSources }) => dataSources.users.getById(parent.authorId) },
};
Step 4: Server Setup with Subscriptions
import { ApolloServer } from '@apollo/server';
import { expressMiddleware } from '@as-integrations/express4';
import { makeExecutableSchema } from '@graphql-tools/schema';
import { WebSocketServer } from 'ws';
import { useServer } from 'graphql-ws/use/ws';
import { createServer } from 'http';
import { PubSub } from 'graphql-subscriptions';
import express from 'express';
import cors from 'cors';
const schema = makeExecutableSchema({ typeDefs, resolvers });
const app = express();
const httpServer = createServer(app);
export const pubsub = new PubSub();
const wsServer = new WebSocketServer({ server: httpServer, path: '/graphql' });
useServer({ schema }, wsServer);
const server = new ApolloServer({ sche
Установить graphql в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл graphql?
Build and consume GraphQL APIs. Use when a user asks to create a GraphQL server, write GraphQL schemas, implement resolvers, set up subscriptions, build a GraphQL API, add authentication to GraphQL, optimize queries with DataLoader, implement pagination, handle file uploads, generate types from schema, consume a GraphQL endpoint, or migrate from REST to GraphQL. Covers Apollo Server, Apollo Client, schema design, resolvers, subscriptions, federation, and production patterns.
Как установить скилл graphql?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл graphql запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic