Postman's GraphQL client is tailored for making GraphQL requests, but you can also create GraphQL requests using Postman's HTTP request interface. The HTTP request interface might be better for some use cases, like working with legacy systems or projects that include both GraphQL and non-GraphQL APIs.
Postman has built-in support for sending GraphQL queries in the request body, using GraphQL variables, and introspection and importing GraphQL schemas.
Select New > HTTP and enter a GraphQL endpoint URL in the URL box.
Select POST
from the request method dropdown list.
Under the Body tab, select the GraphQL body type.
Enter your GraphQL query in the Query editor. The editor enables you to write and edit queries and variables separately.
Select Send.
Enter your GraphQL variables in the GraphQL variables editor.
In the Query editor, declare the GraphQL variable in your query. For more information on how to use GraphQL variables, see the GraphQL variables documentation.
You can also use Postman variables as data inputs for GraphQL variables using
{{variable}}
syntax.
To enable autocompletion while writing queries, your request needs a GraphQL schema. When you enter a GraphQL endpoint URL in the URL box, Postman automatically fetches the GraphQL schema using introspection. When Postman successfully auto-fetches a schema, a notification appears next to the schema selection list. If your schema has changed, select the refresh icon to pull in the changes.
You also have the option to manually import a schema into your request. After creating or importing a GraphQL API into your workspace, you can use that API's schema for your request instead of the auto-fetched schema.
To import a GraphQL schema into your request manually, do the following:
POST
from the request method dropdown list.You may need to refresh by selecting the refresh icon .
When you write your query, Postman suggests autocomplete options from the data in the selected GraphQL schema.
Open a new request tab in Postman and enter your GraphQL endpoint URL in the address field.
Select POST
from the request method dropdown list.
Under the Headers tab, add the Content-type
of application/json
.
Under the Body tab, select the raw body type. Choose JSON from the format dropdown list.
Construct your query in the request body using proper JSON formatting.
Select New > HTTP and enter a GraphQL endpoint URL in the URL box.
Select POST
from the request method dropdown list.
Under the Body tab, select the GraphQL body type.
Under the Headers tab, add the Content-type
of application/graphql
.
Under the Body tab, select the raw body type. Choose Text from the format dropdown list.
Build your query in the request body using standard GraphQL formatting.
POST
request method. Postman opens the request in a new tab with the specified GraphQL endpoint URL and the POST
request method selected.Last modified: 2023/11/15
Additional resources
Videos
Blog posts
Public workspaces