I use
POST type
URL http://######/graphql
Body:
query: \"query: \"{\'noteTypes\': {\'name\', \'label\', \'labelColor\', \'groupName\', \'groupLabel\', \'i
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.
{
"query":{{query}}
}
Step 2.
Create the payload in the pre-request script and store it in an environment variable.
postman.setEnvironmentVariable("query", JSON.stringify(
`
{
search(query: "test", type: ISSUE, first: 10) {
issueCount
edges {
node {
... on Issue {
title
id
state
closed
repository {
name
}
}
}
}
}
}
`
));
That's it.
Postman has recently launched its out of box support for GraphQL: https://blog.getpostman.com/2019/06/18/postman-v7-2-supports-graphql/
Below is the screenshot of testing GraphQL locally:
Note: Running GraphQL locally using spring-boot https://www.baeldung.com/spring-graphql
Postman just released inbuilt GraphQL support in version 7.2.
This version supports
- Sending GraphQL queries in request body as POST requests
- Support for GraphQL variables
- Creating APIs in Postman with GraphQL schema type
- Query autocompletion integrated with user defined GraphQL schemas
Please give it a try and give us your feedback on the tracking thread on our community forum
You don't need INSOMNIA in case the GraphQL server responds to Content-type: application/graphql
or postman.setEnvironmentVariable
,
Just do it:
In Headers tab:
Content-Type: application/graphql
In Body tab, "raw" selected, put your query
By adding header we can run graphql query in the postman
Content-type: application/graphql
UPDATE 8-2019 - I know this is old, but regarding POSTMAN, if you haven't figured it out already, they do have a graphql (beta) option for posting body. There is no need to add any additional headers.