我正在研究基于 Node 的 graphql 项目,试图将 base64 格式的图像发送到服务器。
我正在使用 bodyparser 模块并将其配置为如下所示。
app.use(bodyparser.text({type: 'application/graphql'}));
app.use(bodyparser.json({limit: '50mb'}));
app.use(bodyparser.urlencoded({limit: '50mb', extended: true}));
我可以通过直接 Node 服务发送 base64 图像,但是当涉及到 graphql 服务时,它会抛出错误:
Error: request entity too large
最佳答案
为了帮助其他使用 graphql-yoga npm 包的人。添加 bodyparser 选项的语法完全不同,我花了几个小时调试并试图让它工作,所以在此处添加代码以供引用:
const { GraphQLServer } = require("graphql-yoga");
const server = new GraphQLServer({
schema, //Your schema
context, //Your context
});
const options = {
port: 1234
bodyParserOptions: { limit: "10mb", type: "application/json" },
};
server.start(options, () =>
console.log(
"Server is running\m/"
)
);
关于node.js - 错误 : request entity too large in graphql services of node,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41486401/