pc-graphql-frontend
スター14
フォーク5
更新日2026年5月13日 05:37
前端自定义 GraphQL API 接口. 当需要在前端调用后端自定义接口(非标准 CRUD)时使用
インストール
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SKILL.md
readonlyメニュー
前端自定义 GraphQL API 接口. 当需要在前端调用后端自定义接口(非标准 CRUD)时使用
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Create, analyze, proofread, and modify Office documents (.docx, .xlsx, .pptx) using the officecli CLI tool. Use when the user wants to create, inspect, check formatting, find issues, add charts, or modify Office documents.
tm-ui 组件 API 与源码定位。仅在需要核对某个 tm 组件的 props、events、slots、ref 方法或源码路径时使用;不要用于通用页面开发、样式规范或业务逻辑问题
移动端页面开发规范。开发 UI 界面时使用
创建新业务模块时使用
数据库建表规范。创建新表 SQL 时必须遵循;SQL 建完后必须继续阅读 table-config skill 来生成 {mod}.ts 配置
系统字典和业务字典配置。SQL 中有 dict: 或 dictbiz: 标注的字段时使用
| name | pc-graphql-frontend |
| description | 前端自定义 GraphQL API 接口. 当需要在前端调用后端自定义接口(非标准 CRUD)时使用 |
| compatibility | Vue 3 + TypeScript |
| metadata | {"version":"1.0"} |
src/views/{mod}/{table}/
├── Api.ts # 自动生成, 不放手写自定义接口
└── Api2.ts # 手写自定义接口
Api.ts 为生成文件, 尽量不改src/views/{mod}/{table}/Api2.ts./Api2.ts 导入, 以减少与生成代码的 git 冲突query() / mutation() 时会由全局错误处理器统一处理,这条规则不适用于其他异步操作query() 会在同一轮 microtask 内自动合并/去重多个查询;彼此独立的查询尽量一起发起,再 await Promise.all(...)import type {
Query,
} from "#/types.ts";
/** 接口描述 */
export async function 函数名(
id: XxxId,
opt?: GqlOpt,
) {
const res: {
函数名: Query["函数名"];
} = await query({
query: /* GraphQL */ `
query($id: XxxId!) {
函数名(id: $id) {
field1
field2
}
}
`,
variables: { id },
}, opt);
const data = res.函数名;
return data;
}
query() 和 mutation() 由 @/utils/graphql 导入, 无需手动引入 vite 会自动注入import type {
Mutation,
XxxInput,
} from "#/types.ts";
/** 接口描述 */
export async function updateXxx(
id: XxxId,
input: XxxInput,
opt?: GqlOpt,
) {
const res: {
updateXxx: Mutation["updateXxx"];
} = await mutation({
query: /* GraphQL */ `
mutation($id: XxxId!, $input: XxxInput!) {
updateXxx(id: $id, input: $input)
}
`,
variables: {
id,
input,
},
}, opt);
const data = res.updateXxx;
return data;
}
#/types.ts 导入 Query、Mutation、XxxInput 等 GraphQL 相关类型;标准的 {Table}Model、{Table}Input、{Table}Search 无需额外引入,因为已经在 Model.ts 中全局定义。Query["xxx"] 或 Mutation["xxx"] 声明返回值。