我正在尝试使用express-gateway
.
网关上的代码如下,
const axios = require("axios");
const jsonParser = require("express").json();
const { PassThrough } = require("stream");
module.exports = {
name: 'gql-transform',
schema: {
... // removed for brevity sakes
},
policy: (actionParams) => {
return (req, res, next) => {
req.egContext.requestStream = new PassThrough();
req.pipe(req.egContext.requestStream);
return jsonParser(req, res, () => {
req.body = JSON.stringify({
...req.body,
variables: {
...req.body.variables,
clientID: '1234'
}
});
console.log(req.body); // "clientID": "1234" is logged in the body.variables successfully here
return next();
});
};
}
};
现在,当我从 POSTMAN 发出请求时,请求通过并仅在我 include 时返回 200OK clientID
,否则,它会抛出错误
“消息”:“未提供所需类型“ID!”的变量“$clientID”。
知道这里可能出了什么问题吗?