【问题标题】:Facing issue while uploading image using Graphql and apollo server使用 Graphql 和 apollo 服务器上传图像时面临问题
【发布时间】:2020-01-30 10:05:56
【问题描述】:

使用 graphql 上传图片时遇到问题。当我使用邮递员测试以下查询时,出现错误(如下所示)。

查询:

{"query":"mutation($file: Upload) {sendImage(file: $file)
  }","variables":{"file":null}}

错误:

BadRequestError:“操作”多部分字段 (https://github.com/jaydenseric/graphql-multipart-request-spec) 中的 JSON 无效。

【问题讨论】:

  • 我正在为 graphql 使用 apollo-server

标签: image graphql image-uploading apollo-server


【解决方案1】:

默认情况下,结果以application/json有效载荷发送,但对于文件上传,您需要发出多部分请求。

您可以按照link 使用邮递员发出多部分请求。

Read more about file upload

【讨论】:

  • 我做了同样的改变,但没有改善
  • @vignesh 你能分享你的多部分请求吗?
猜你喜欢
  • 2021-10-04
  • 2019-08-20
  • 1970-01-01
  • 2021-03-04
  • 2017-06-22
  • 2020-06-21
  • 1970-01-01
  • 2021-04-25
  • 2019-08-15
相关资源
最近更新 更多