Graphql帖子主体“必须提供查询字符串". [英] Graphql post body "Must provide query string."

查看:475
本文介绍了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字符串太短.我必须发送更新模型,例如

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 request needs to manage headers info.

  1. 使用Http客户端:Content-Type application/json

  1. Using Http client: Content-Type application/json

使用Postman客户端:Content-Type application/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屋!

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