一键导入
tpl-backend-graphql-apollo
Template do pack (backend/05-graphql-apollo.md). Orienta o agente em APIs, servicos e arquitetura backend alinhado a esse contexto.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Template do pack (backend/05-graphql-apollo.md). Orienta o agente em APIs, servicos e arquitetura backend alinhado a esse contexto.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generate custom favicons from logos, text, or brand colours. Produces favicon.svg, favicon.ico, apple-touch-icon.png, icon-192/512.png, and web manifest. Use whenever the user wants a favicon, mentions replacing a CMS default favicon, converting a logo into a favicon, creating branded initials icons, or troubleshooting favicon not displaying / iOS black square / missing manifest.
"Get a second opinion from leading AI models on code, architecture, strategy, prompting, or anything. Queries models via OpenRouter, Gemini, or OpenAI APIs. Supports single opinion, multi-model consensus, and devil's advocate patterns. Use whenever the user says 'brains trust', 'second opinion', 'ask gemini', 'ask gpt', 'peer review', 'consult another model', 'challenge this', or 'devil's advocate'."
Run an independent code review using the OpenAI Codex CLI in headless mode. Gets a second opinion from a different model family (GPT-5/o3) on recent changes, a PR, a commit, or the whole app — covering bugs, regressions, security, data consistency, UX/state bugs, performance risks, and testing gaps. Saves a severity-prioritised report to .jez/reviews/. Triggers: 'codex review', 'review with codex', 'second opinion on this code', 'independent code review', 'what does codex think', 'get codex to review'.
Deep research and discovery before building something new. Explores local projects for reusable code, researches competitors, reads forums and reviews, analyses plugin ecosystems, investigates technical options, and produces a comprehensive research brief. Three depths: focused (30 min), wide (1-2 hours), deep (3-6 hours). Triggers: 'research this', 'deep research', 'discovery', 'explore the space', 'what should I build', 'competitive analysis', 'before I start building', 'research before coding'.
Plan and execute entire application builds. Generates phased delivery roadmaps, then executes them autonomously — phase by phase, committing at milestones, deploying, testing, and continuing until done or stuck. Modes: plan (generate roadmap), start (begin executing), resume (continue from where you left off), status (show progress). Triggers: 'roadmap', 'plan the build', 'start building', 'resume the build', 'keep going', 'build the whole thing', 'execute the roadmap', 'what phase are we on'.
Walk through a live web app AS a real user to find usability + behavioural bugs that static reviews miss. REQUIRES proof of interaction (typing, clicking, sending, observing) before any verdict — a sweep that didn't interact terminates with verdict 'Incomplete'. Walks threads, exercises every element, runs the multi-pane stress matrix, visual polish sweep, component perfection checklist, automated a11y (axe-core), pragmatic performance budget (LCP/CLS/INP), scenario battery (11 scenarios), and stress recipes including the real-flavour data battery. Hard gates: console errors/warnings = 0, network 5xx = 0, layout collapse = 0, axe Critical/Serious = 0, perf budget green. Audit-the-audit meta-check rejects rushed reports. Each finding has reproduction steps, evidence path, and suspected code location. Trigger with 'ux audit', 'walkthrough', 'qa sweep', 'audit the app', 'dogfood this', 'check all pages', 'find what's broken', 'stress the UI'.
| name | tpl-backend-graphql-apollo |
| description | Template do pack (backend/05-graphql-apollo.md). Orienta o agente em APIs, servicos e arquitetura backend alinhado a esse contexto. |
| metadata | {"version":"1.0.0","source_template":"backend/05-graphql-apollo.md","generated_by":"install_pack_templates_as_claude_skills"} |
Skill gerado a partir do pack templates-claude-code. Arquivo de origem: backend/05-graphql-apollo.md. Use como baseline e adapte ao projeto antes de mudancas grandes.
| Technology | Version | Purpose |
|---|---|---|
| Node.js | 22.x | Runtime |
| TypeScript | 5.4+ | Language |
| Apollo Server | 4.x | GraphQL server |
| GraphQL | 16.x | Query language |
| Prisma | 5.x | ORM + migrations |
| PostgreSQL | 16 | Primary database |
| DataLoader | 2.x | Batching + caching (N+1 prevention) |
| Zod | 3.x | Input validation |
| jsonwebtoken | 9.x | JWT tokens |
| Vitest | 1.x | Unit tests |
| graphql-ws | 5.x | WebSocket-based subscriptions |
src/
├── schema/
│ ├── typeDefs/
│ │ ├── user.graphql # SDL type definitions
│ │ ├── post.graphql
│ │ └── auth.graphql
│ └── index.ts # mergeTypeDefs + makeExecutableSchema
├── resolvers/
│ ├── user/
│ │ ├── queries.ts # User queries
│ │ ├── mutations.ts # User mutations
│ │ └── fields.ts # Field resolvers (e.g., User.posts)
│ ├── auth/
│ │ ├── mutations.ts
│ │ └── subscriptions.ts
│ └── index.ts # mergeResolvers
├── dataloaders/
│ ├── userLoader.ts # DataLoader for batching user queries
│ ├── postLoader.ts
│ └── index.ts # Loader factory per request
├── services/
│ └── users/
│ └── users.service.ts
├── context/
│ └── index.ts # Context builder (auth + loaders + prisma)
├── middleware/
│ └── auth.ts # Token extraction + user injection
├── lib/
│ └── prisma.ts # Prisma client singleton
├── server.ts # Apollo Server + Express setup
└── generated/
└── graphql.ts # codegen output (never edit manually)
prisma/
├── schema.prisma
└── migrations/
codegen.yml
.graphql SDL files first, then resolverscontext.usercodegen.yml regenerated whenever schema changes: npx graphql-codegen| Use Schema-First (SDL) | Use Code-First |
|---|---|
| Team has frontend + mobile consumers | Solo backend dev, schema evolves fast |
| Contract-first with external teams | TypeScript-centric team, schema from types |
| This project's choice ✅ | Schema-as-code preference |
// src/resolvers/user/queries.ts
import { z } from 'zod'
import { QueryResolvers } from '../../generated/graphql'
import { UserService } from '../../services/users/users.service'
import { GraphQLError } from 'graphql'
const paginationSchema = z.object({
first: z.number().int().min(1).max(100).default(20),
after: z.string().optional(),
})
export const userQueries: QueryResolvers = {
me: async (_parent, _args, context) => {
if (!context.user) {
throw new GraphQLError('Not authenticated', {
extensions: { code: 'UNAUTHENTICATED' },
})
}
return context.services.users.getById(context.user.id)
},
users: async (_parent, args, context) => {
if (!context.user?.isAdmin) {
throw new GraphQLError('Not authorized', {
extensions: { code: 'FORBIDDEN' },
})
}
const { first, after } = paginationSchema.parse(args)
return context.services.users.list({ first, after })
},
}
// src/resolvers/user/fields.ts — NEVER query DB here, use DataLoader
import { UserResolvers } from '../../generated/graphql'
export const UserFieldResolvers: UserResolvers = {
posts: async (parent, _args, context) => {
// DataLoader batches all `posts` field calls in a single query
return context.loaders.postsByUserId.load(parent.id)
},
// total is computed, not stored
postCount: async (parent, _args, context) => {
const posts = await context.loaders.postsByUserId.load(parent.id)
return posts.length
},
}
DataLoaders MUST be created fresh per request to avoid cross-request cache pollution.
// src/dataloaders/userLoader.ts
import DataLoader from 'dataloader'
import { prisma } from '../lib/prisma'
import type { User } from '@prisma/client'
export function createUserLoader() {
return new DataLoader<string, User | null>(
async (ids: readonly string[]) => {
const users = await prisma.user.findMany({
where: { id: { in: ids as string[] } },
})
// Result MUST be in same order as input ids
const userMap = new Map(users.map(u => [u.id, u]))
return ids.map(id => userMap.get(id) ?? null)
},
{ cache: true } // cache within a single request context
)
}
// src/dataloaders/index.ts
export function createLoaders() {
return {
userById: createUserLoader(),
postsByUserId: createPostsByUserIdLoader(),
}
}
// src/context/index.ts
import { Request } from 'express'
import { prisma } from '../lib/prisma'
import { createLoaders } from '../dataloaders'
import { verifyToken } from '../middleware/auth'
import { UserService } from '../services/users/users.service'
export async function buildContext({ req }: { req: Request }) {
const user = verifyToken(req.headers.authorization) // null if unauthenticated
return {
user,
prisma,
loaders: createLoaders(), // new instances per request
services: {
users: new UserService(prisma),
},
}
}
export type GraphQLContext = Awaited<ReturnType<typeof buildContext>>
// src/resolvers/auth/subscriptions.ts
import { SubscriptionResolvers } from '../../generated/graphql'
import { PubSub } from 'graphql-subscriptions'
export const pubsub = new PubSub()
export const USER_JOINED = 'USER_JOINED'
export const authSubscriptions: SubscriptionResolvers = {
userJoined: {
subscribe: (_parent, _args, context) => {
if (!context.user?.isAdmin) throw new Error('Forbidden')
return pubsub.asyncIterator([USER_JOINED])
},
resolve: (payload) => payload.userJoined,
},
}
| Trigger | Operation | Field | Auth | Resolver |
|---|---|---|---|---|
| Get self | Query | me | Bearer | userQueries.me |
| List users | Query | users(first, after) | Bearer + Admin | userQueries.users |
| Get user | Query | user(id) | Bearer + Admin | userQueries.user |
| Register | Mutation | register(input) | Public | authMutations.register |
| Login | Mutation | login(input) | Public | authMutations.login |
| Refresh | Mutation | refreshToken(token) | Public | authMutations.refresh |
| Update profile | Mutation | updateMe(input) | Bearer | userMutations.updateMe |
| Delete account | Mutation | deleteAccount | Bearer | userMutations.deleteAccount |
| New user joined | Subscription | userJoined | Bearer + Admin | authSubscriptions.userJoined |
Before opening a PR, verify ALL of the following:
npx tsc --noEmit passes — no type errors in resolvers or contextnpx graphql-codegen run — generated types match current schemavitest run passes with zero failuresextensions.code set on all GraphQLError throws (UNAUTHENTICATED, FORBIDDEN, BAD_USER_INPUT)any in resolver return types — use generated types from codegencontext.prisma directly in field resolvers — use context.loadersGraphQLErrorextensions.code on GraphQL errors — clients need machine-readable codes.graphql files and codegengraphql-subscriptions PubSub in production with multiple instances — use Redis PubSubintrospection: process.env.NODE_ENV !== 'production')