uni-graphql-frontend
스타14
포크5
업데이트2026년 5월 13일 05:37
uni 前端自定义 GraphQL API 接口。需要在 uni 页面调用后端自定义接口时使用
설치
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SKILL.md
readonly메뉴
uni 前端自定义 GraphQL API 接口。需要在 uni 页面调用后端自定义接口时使用
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 | uni-graphql-frontend |
| description | uni 前端自定义 GraphQL API 接口。需要在 uni 页面调用后端自定义接口时使用 |
| compatibility | Uni-app + TypeScript |
| metadata | {"version":"1.0"} |
src/pages/{table}/
├── Api.ts # 自动生成, 不放手写自定义接口
└── Api2.ts # 手写自定义 GraphQL 接口
Api.ts 为生成文件, 尽量不改src/pages/{table}/Api2.ts./Api2.ts 导入, 避免和生成代码混改query()、mutation()、request()、GqlOpt 由自动导入提供, 一般不需要手动 import| 场景 | 调用方式 | 说明 |
|---|---|---|
| GraphQL 查询 | query() | 不要改成 request({ reqType: "graphql" }), 也不要自己写 uni.request 打 /graphql |
| GraphQL 变更 | mutation() | 会自动补 Request-ID, 用于后端幂等和重复提交保护, 不要在业务代码里重复拼同类 header |
| 非 GraphQL 普通接口 | request() | 默认优先走这个封装 |
| 下载原始 html、附件、第三方地址 | request() 或 uni.request | 只有响应不是标准 GraphQL 结构时, 才直接用 uni.request |
Api2.ts 里包一层 try/catch; 当前封装已经统一处理 loading、toast、鉴权失效、token 刷新、TenantId 和响应头里的 authorizationquery() 会在同一轮 microtask 里自动合并/去重 GraphQL 查询; 多个彼此独立的查询先一起发起, 再 await Promise.all(...), 不要串行一个个等import type {
Query,
} from "#/types.ts";
/** 接口描述 */
export async function getCurrentUsrCard(
opt?: GqlOpt,
) {
const res: {
getCurrentUsrCard: Query["getCurrentUsrCard"];
} = await query({
query: /* GraphQL */ `
query {
getCurrentUsrCard {
id
lbl
}
}
`,
}, opt);
return res.getCurrentUsrCard;
}
import type {
Mutation,
CardRechargeInput,
} from "#/types.ts";
/** 接口描述 */
export async function payCardRecharge(
input: CardRechargeInput,
opt?: GqlOpt,
) {
const res: {
payCardRecharge: Mutation["payCardRecharge"];
} = await mutation({
query: /* GraphQL */ `
mutation($input: CardRechargeInput!) {
payCardRecharge(input: $input) {
timeStamp
nonceStr
package
signType
paySign
}
}
`,
variables: {
input,
},
}, opt);
return res.payCardRecharge;
}
Query["xxx"] 或 Mutation["xxx"]#/types.ts 导入这类场景通常不是 GraphQL 响应结构, 应改用 request() 或 uni.request, 不要硬塞进 query() / mutation()。