变量$file获得无效值{};上载值无效



我正试图用postmen将一个文件上传到graphql服务器。但我得到了这个错误(变量$file得到了无效的值{};上传值无效(。请帮我解决这个问题。我正在使用typegraphql来构建API。

operation: {"query":"mutation($file: Upload!) {n uploadFile(file: $file)n}"}

map: {"0": ["variables.file"]}

0: file.png

如果使用graphql-uploadapollo-server-express,则可能需要在ApolloServer配置中将uploads设置为false,然后从graphql-upload使用graphqlUploadExpress()

例如:

app = express();
new ApolloServer({ schema, context, uploads: false });
app.use(graphqlUploadExpress({ maxFileSize: 10000, maxFiles: 10 }));
server.applyMiddleware({ app });

相关内容

最新更新