import type { Context } from "@wundergraph/sdk";
import type { User } from "generated/wundergraph.server";
import type { InternalClient } from "generated/wundergraph.internal.client";
import { InjectedGetCountryInput, GetCountryResponse } from "generated/models";
// 在左侧引入当前包
import axios from "axios";
export default async function mutatingPostResolve(
ctx: Context<User, InternalClient>,
input: InjectedGetCountryInput,
response: GetCountryResponse
): Promise<GetCountryResponse> {
var country = response.data?.country;
if (country) {
country.phone = "fireboom/test"; //这里可以修改返回值
}
ctx.log.info("test");
//触发一个post请求,给企业机器人发送一个消息
var res = await axios.post(
"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=[YOUR KEY]",
{
msgtype: "markdown",
markdown: {
content: `<font color="warning">${
ctx.clientRequest.method
}</font>/n输入:${JSON.stringify(input)}/n响应:${JSON.stringify(
response
)}`,
},
}
);
ctx.log.info("mutatingPostResolve SUCCESS:", res.data);
return response;
}