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."
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 theCopy as cURL (cmd)
Step 3.
Open Postman, In the Top-Left click on the
Import
button, after you clickImport
you have to click thePaste Raw Text
, and paste the copiedcURL
request as done in step2 after it's done click theImport
Step 4.
Postman is ready to send the Graphql request, Just Click on the
Send
Button, you will see theResponse
in the Response Box in body as belowStep 5.
To see how the query is being sent click on the
Body
tab next toHeaders
, 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".."
===========================================================================
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 postmanWith simplified JSON
You don't need INSOMNIA in case the GraphQL server responds to
Content-type: application/graphql
orpostman.setEnvironmentVariable
,Just do it:
In Headers tab:
Content-Type: application/graphql
In Body tab, "raw" selected, put your query
There's a simple way to do it. Use a pre-request script to stringify the payload (source).
Step 1.
In the body of the request put a placeholder for the payload.
Step 2.
Create the payload in the pre-request script and store it in an environment variable.
That's it.
UPDATE 2:
It's not practical use POSTMAN, because the are working yet in a easy way to add headers, that take longtime, and i think POSTMAN is not made for work naturally with graphql,
you can follow the progress about that here: https://github.com/postmanlabs/postman-app-support/issues/1669
I recommend to use another packages plugin like:
for graphiql (no add headers possibility) you need to set three things (it's not easy to type):
Header:
Content-Type: application/json
Body:
Choose Ray < optiongroup
Choose JSON (application/json) < selectbox
Compose javascript object with "query" and the "value" of your graph query. Like all objects in js it'sneeded the propery and the value , in this case "quote" is the property, the value must be with double quotes. Inside the value (graphl string) you dont compose js objects, so you dont need use doble quotes, it's just a string.
{"query":"{ allQuotes { text } }" }
the problem is you need type all in a single line, no like grapIql... there is a post requirement in postman github so is easy work with graphql:
Adding this for anyone searching on the topic ... you can utilize and test GraphQL calls far better and more easily with Insomnia:
https://insomnia.rest
It's been fantastic for GraphQL development.
I faced the same problem when I try to used
graphQl
query usingPOSTMAN
, In POSTMAN send data from theraw
tab withjson
type.Query Command:
Mutations Command: