有没有办法通过邮递员将文件上传到 GraphQL API? [英] Is there any way to upload files via postman into a GraphQL API?

查看:71
本文介绍了有没有办法通过邮递员将文件上传到 GraphQL API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在使用 Altair 将文件(在我的情况下仅用于图像)上传到我的 GraphQL API.但是,我所有的其他路由都存储在邮递员中,如果我可以只使用一个应用程序 - 邮递员 - 就​​可以了.

Currently I'm using Altair to upload files (in my case it's just for images) to my GraphQL API. However, all my other routes are stored in postman and it'd be nice if I could use just one application - Postman - for everything.

在 Altair 中,我可以简单地选择一个图像并将其存储为一个变量,我将其作为 GraphQL 上传字段的值.

In Altair I can simply select an image and store that as a variable that I put as the value for my GraphQL Upload field.

有谁知道 Postman 是否支持那个(或类似的)功能?

Does anyone know if Postman supports that (or a similiar) feature?

谢谢!

推荐答案

您可以使用 Form-Data 来做到这一点.

You can use Form-Data to do this.

关键:操作(这是用于查询/变异)

Key: Operations (this is for the query / mutation )

{"query":"mutation updateAvatar($avatar:Upload!) {\n  updateAvatar(avatar: $avatar)\n}"}

键:映射(这是将文件映射到您的查询/变异)

Key: map ( this is to map the files to your query / mutation )

{"0": ["variables.avatar"]}

键:0(上传你的图片/文件等)

Key: 0 ( upload your image/file etc )

这篇关于有没有办法通过邮递员将文件上传到 GraphQL API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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