用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/UitbreidenOS/UitKit --skill graphql命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Guidelines and instructions for Agent execution state rollback rules
Guidelines and instructions for Agent execution step counters limits
Guidelines and instructions for Agent execution timeout limits setups
基于 SOC 职业分类
正在显示 SKILL.md
| name | graphql |
| description | GraphQL schema design, resolvers, mutations, subscriptions, DataLoader, Prisma integration, N+1 prevention |
# Type names: PascalCase singular nouns
# Field names: camelCase
# Enums: SCREAMING_SNAKE_CASE values
type Order {
id: ID!
status: OrderStatus!
customer: Customer! # Nested type — always return the object, not just the ID
items: [OrderItem!]! # Non-null list of non-null items
totalAmount: Float!
createdAt: DateTime!
}
enum OrderStatus {
PENDING
COMPLETED
CANCELLED
}
# Queries: return nullable for single item (not found = null), non-null for lists
type Query {
order(id: ID!): Order # Nullable — null if not found
orders(filter: OrderFilter): [Order!]! # Non-null list
me: User # Nullable — null if not authenticated
}
# Mutations: always return the mutated object plus an errors array
type Mutation {
createOrder(input: CreateOrderInput!): CreateOrderPayload!
}
type CreateOrderPayload {
order: Order # Null if mutation failed
errors: [UserError!]! # Empty if successful
}
type UserError {
field: String
message: String!
}
import DataLoader from 'dataloader';
// Create per-request — never singleton (request data isolation)
export function createLoaders() {
return {
customerLoader: new DataLoader<string, Customer>(async (ids) => {
const customers = await db.customer.findMany({
where: { id: { in: [...ids] } }
});
// Must return in same order as ids
const customerMap = new Map(customers.map(c => [c.id, c]));
return ids.map(id => customerMap.get(id) ?? new Error(`Customer ${id} not found`));
}),
};
}
// Resolver — uses loader, not direct DB call
const resolvers = {
Order: {
customer: (order, _, { loaders }) => loaders.customerLoader.load(order.customerId),
}
};
type OrderConnection {
edges: [OrderEdge!]!
pageInfo: PageInfo!
totalCount: Int!
}
type OrderEdge {
node: Order!
cursor: String!
}
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
type Query {
orders(first: Int, after: String, last: Int, before: String): OrderConnection!
}
// Field-level authorization in resolver
const resolvers = {
Query: {
adminStats: (_, __, { user }) => {
if (!user || user.role !== 'ADMIN') {
throw new GraphQLError('Unauthorized', {
extensions: { code: 'UNAUTHORIZED' }
});
}
return getAdminStats();
}
},
Order: {
// Object-level: only return sensitive fields to the order's owner
internalNotes: (order, _, { user }) => {
if (user?.id !== order.customerId && user?.role !== 'ADMIN') return null;
return order.internalNotes;
}
}
};
// Resolver using Prisma — avoid over-fetching
const resolvers = {
Query: {
order: async (_, { id }, { prisma, user }) => {
const order = await prisma.order.findUnique({
where: { id },
select: {
id: true,
status: true,
customerId: true,
totalAmount: true,
createdAt: true,
// Do NOT select items here — let the items resolver handle it
// with DataLoader to avoid N+1
}
});
if (!order) return null;
if (order.customerId !== user?.id) throw new GraphQLError('Forbidden');
return order;
}
}
};
User: Design a GraphQL schema and resolvers for a simple e-commerce API — products, orders, and customers. Include pagination, DataLoader for customers, and mutation error handling.
Expected output:
Product, Order, Customer, OrderConnection, UserError typesQuery.orders with cursor pagination returning OrderConnectionMutation.createOrder returning CreateOrderPayload with errors arrayOrder.customer resolver using DataLoader (not direct DB query)createLoaders() function per request, batching customer lookups by ID