Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send graphql query by postman?

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."

like image 753
ZPPP Avatar asked Feb 28 '17 23:02

ZPPP


People also ask

How do I test a query in GraphQL?

We saw why not testing your app is not an option and how you can test your GraphQL endpoint: test your schema with eslint-plugin-graphql and schema-graphql-linter. test your queries and mutations with EasyGraphQL Tester. test your resolvers like you would test any other Javascript function.

How to use postman With GraphQL?

The above schema can be loaded in the Postman API section — just add New API with GraphQL type and press Generate Collection: Once we load our schema, we can easily write sample queries using Postman's autocomplete support for GraphQL. 3. GraphQL Requests in Postman

What is postman's query auto-completion?

Query auto-completion is one of the most popular aspects of Postman's GraphQL support. The query auto-completion is powered by Postman API schemas. To create a GraphQL API schema in Postman: GraphQL enthusiasts ranging from industry consultants to product builders gathered at Postman Galaxy 2021 to share their experiences in the GraphQL landscape…

How do I write a postman query in Python?

We begin by opening postman and selecting the option to write a new query. Next, we begin the query by first writing the URL of the request. In our case, that’ll be @ http://localhost:4000/.

How many GraphQL post body must provide query string?

49 Graphql post body "Must provide query string." 2 Java Programmatically send GraphQL REST Query 0 GraphQL POST query 1 Sangria simple graphQL query, but syntax error


1 Answers


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...

enter image description here

Step 2.

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

enter image description here

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

enter image description here

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

enter image description here

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 }}}}}" } 

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

enter image description here

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

enter image description here

With simplified JSON

enter image description here

like image 168
Parwat Kunwar Avatar answered Sep 30 '22 15:09

Parwat Kunwar