本文介绍了如何通过邮递员发送graphql查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

  POST类型
URL http:// ###### / graphql
正文:
查询:查询: {'noteTypes':{'name','label','labelColor','groupName','groupLabel','imageUrl'}}

但是它返回
消息:必须提供查询字符串。

解决方案




使用REST客户端有一种更好的方法



第2步。



从 graphql 请求复制请求查询,选择另存为cURL(cmd)





第3步。



打开邮递员,在顶部-左键单击导入按钮,单击导入后,您必须单击粘贴Raw Text ,然后按照步骤2中的步骤粘贴复制的 cURL 请求,点击完成后,点击导入





第4步。



邮递员已准备好发送Graphql请求,只需单击发送按钮,您将看到响应在下面的响应框中





第5步。



要查看查询的发送方式,请点击标头旁边的正文标签,您将知道如何以JSON格式提供邮递员的字段。



例如: edges {\n节点{\n id\n jobId\n} \n ,如果要查看另一个字段,然后需要添加后缀 \n



,如需要 name 然后: edges {\n节点{\n id\n jobId\n name\n} \n



\n 这里只是表示换行。相反,您可以通过提供如下所示的清晰说明性JSON来简化操作



================ ================================================== ========



注意 :主体类型必须是原始的具有 application / json 内容类型。因此,查询必须是带引号 ..

  {
query: {viewer {user {edges {node {id jobId name}}}}}
}

================================= =======================================





您可以直接从第5步如果您知道如何在正文中发送查询以及在向邮递员提出请求时也需要进行其他操作





使用简化的JSON




I use

POST type
URL http://######/graphql
Body:
query: "query: "{'noteTypes':  {'name', 'label', 'labelColor', 'groupName', 'groupLabel', 'imageUrl'}}"

But it return"message": "Must provide query string."

解决方案


There's a better way to do it using the REST client Insomnia

Docs are here, how to send graphql queries: https://support.insomnia.rest/article/61-graphql


Below are the steps for postman

Step 1.

Run the GraphiQL in Chrome, open the Chrome Dev Console, click the Network tab, and make the query from graphiql, when you make the query, network tab will show the graphql request...

Step 2.

From the graphql request copy the request query, Select the Copy as cURL (cmd)

Step 3.

Open Postman, In the Top-Left click on the Import button, after you click Import you have to click the Paste Raw Text, and paste the copied cURL request as done in step2 after it's done click the Import

Step 4.

Postman is ready to send the Graphql request, Just Click on the Send Button, you will see the Response in the Response Box in body as below

Step 5.

To see how the query is being sent click on the Body tab next to Headers, you will get know how to provide the fields from postman in JSON format.

e.g: edges {\n node {\n id\n jobId\n }\n, If you want to view another field then you need to add it in with the suffix \n

like if need name then : edges {\n node {\n id\n jobId\n name\n }\n

\n here just means to represent a new line. Instead, you can make it simpler by providing a clear and illustrative JSON like below

===========================================================================

Note: The body type must be raw with application/json content-type. So, the query must be a valid JSON with quotes ".."

{
   "query":"{viewer {user {edges {node {id jobId name }}}}}"
}

===========================================================================

you can directly start from step 5 if you know how to send the query in body and other things too that needs to be required while making a request from postman

With simplified JSON

这篇关于如何通过邮递员发送graphql查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-23 05:25