Postman - 使用 GraphQL 上传文件和其他参数 [英] Postman - Upload file and other argument with GraphQL

查看:26
本文介绍了Postman - 使用 GraphQL 上传文件和其他参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Postman 将文件上传到 GraphQL.

I am trying to use Postman to upload a file to GraphQL.

我知道如何上传文件,但是,在我的更改中,我必须将 String!Upload! 一起传递.

I know how I can upload a file, however, in my mutation I have to pass a String! together with the Upload!.

我不确定在 Postman 中我可以在哪里传递这个 String!.

I am not sure where I can pass this String! in Postman.

我的突变:

mutation AddBookImageOne($bookId: string, $bookImageOne: Upload!){
  addBookImageOne(bookId: $bookId, bookImageOne: $bookImageOne)
}

我试图在 variables 键中传递 bookId 但我一直收到错误:

I tried to pass bookId in the variables key but I keep getting the error:

"message":"变量"$bookId"所需类型字符串!"没有提供.",

"message": "Variable "$bookId" of required type "String!" was not provided.",

我检查了这个:Graphql 突变以上传其他字段的文件但他们使用 CURL

I checked this: Graphql mutation to upload file with other fields but they use CURL

操作"在邮递员领域是:

{"query":"mutation AddBookImageOne($bookId: String!, $bookImageOne: Upload!){
  addBookImageOne(bookId: $bookId, bookImageOne: $bookImageOne)
}"}

推荐答案

SOLVED 感谢 @xadm

我必须在 operations 字段中传递变量,例如:

I had to pass the variables in the operations field like:

{"query":"mutation AddBookImageOne($bookId: String!, $bookImageOne: Upload!){
  addBookImageOne(bookId: $bookId, bookImageOne: $bookImageOne)
}", "variables": { "bookImageOne": null, "bookId": "be96934c-d20c-4fad-b4bb-a1165468bad9" } }`

这篇关于Postman - 使用 GraphQL 上传文件和其他参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆