Graphql 帖子正文“必须提供查询字符串". [英] Graphql post body "Must provide query string."
本文介绍了Graphql 帖子正文“必须提供查询字符串".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 Express-graphql 中间件.我在正文行中发送以下请求:
I use Express-graphql middleware. I send the following request in the body line:
POST /graphql HTTP/1.1
Host: local:8083
Content-Type: application/graphql
Cache-Control: no-cache
Postman-Token: d71a7ea9-5502-d5fe-2e36-0ae49c635a29
{
testing {
pass(id: 1) {
idn
}
}
}
并且有错误
{
"errors": [
{
"message": "Must provide query string."
}
]
}
在 graphql 中,我可以在 URL 中发送更新.
in graphql i can send update in URL.
网址字符串太短.我必须像
URL string is too short. i must send update model like
mutation {
update(id: 2, x1: "zazaza", x2: "zazaza", x3: "zazaza" ...(more more fields)...) {
idn
}
}
我认为它必须在请求正文中.我如何发送更新"查询或我做错了什么?
i think its must be in request body. How can i send 'update' query or that i'm doing wrong?
推荐答案
Post 请求需要管理 headers 信息.
Post request needs to manage headers info.
使用 Http 客户端:Content-Type application/json
Using Http client: Content-Type application/json
使用 Postman 客户端:Content-Type 应用程序/graphql
Using Postman client: Content-Type application/graphql
但请求正文看起来像字符串
but request body looks like string
{"query":"mutation{update(id:1,x1:"zazaz",x2:"zazaz"......){id x1 x2}}"}
这篇关于Graphql 帖子正文“必须提供查询字符串".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文