graphql-contract
Use when changing GraphQL schema, resolvers, or frontend GraphQL documents so the contract and codegen stay in sync.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
GraphQL contract & sync
When to use
- You modify backend GraphQL types/resolvers or the schema.
- You add or edit frontend
.graphqldocuments. - You suspect schema and generated types are out of sync.
Steps
- Backend: implement changes under
backend/src/backend/apps/**/graphql/. - Sync: run
task frontend:codegenfrom the repo root.- This runs
task backend:schema:exportto updatefrontend/schema/schema.graphql. - Then runs
pnpm codegento regenerate TypeScript types.
- This runs
- Frontend: update
frontend/src/to use the newly generated types/fragments. - Verify: run
task frontend:check.
Constraints and guardrails
- The Strawberry backend is the source of truth; do not manually edit
frontend/schema/schema.graphql. - Do not hand-write TypeScript interfaces for GraphQL results; use generated
types in
frontend/src/lib/graphql/. - Schema changes and frontend sync should be in the same change set.
- Breaking changes (removing/renaming fields,
Nullable → Non-Null, adding required args) require immediate frontend updates after codegen. - Avoid N+1 by using SQLAlchemy eager loading (
selectinload/joinedload) and moving complex logic into services.
References
-
backend/src/backend/apps/**/graphql/ -
frontend/schema/schema.graphql -
frontend/src/lib/graphql/ -
frontend/**/codegen.*
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!