繁体   English   中英

graphql apollo-server 中的文件上传错误

[英]File upload error in graphql apollo-server

我正在学习 graphql 。我跟着这篇文章https://dev.to/dnature/handling-file-uploads-with-apollo-server-2-0-14n7#:~:text=With%20Apollo%20Server%202.0% 2C%20you,a%20cloud%20storage%20provider%20 代替 用于使用 graphql apollo-server 上传文件,但在图像文件夹中为响应和空文件获得无限缓冲。

我确定以下两个文件中存在错误

变异文件

模式文件

您需要使用yarn add graphql-upload添加graphql-upload包。 然后你需要在 ApolloServer 创建里面做一些修改到主服务器文件中,

const apolloServer = new ApolloServer({
    schema,
    resolvers,
    uploads: false, // add this
  });

然后你需要在你的主服务器文件中从graphql-upload添加graphqlUploadExpress中间件,

  app.use(graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 }));

有关更多信息,请参阅此 github 问题https://github.com/MichalLytek/type-graphql/issues/37#issuecomment-592467594

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM