Querying with GraphQL

Many people think of Postman as an advanced REST client. Beyond REST, Postman is a tool that handles any calls sent over HTTP. This means that you can use Postman to interact with protocol-agnostic APIs - such as SOAP and GraphQL, which can both utilize HTTP, just like REST.

Learn how Postman supports working with GraphQL.

  • 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

Try it out in Postman with this example template.

graphql template

Sending a GraphQL query


There's a few ways for you to author and send a GraphQL query in Postman. The following screen illustrates one way to send a GraphQL query using Postman's inbuilt support.

graphql body

Under the Body tab, select the GraphQL body type. Enter your GraphQL query in the Query editor. This editor enables you to author both queries and variables separately, as described in the following section.

Working with GraphQL variables

Postman provides a separate interface to author GraphQL variables. After defining your GraphQL query in the Query editor, you can author and edit GraphQL variables in the adjacent variables editor.

You can also use Postman variables as data inputs for GraphQL variables using {{variable}} syntax.

edit variables

Importing GraphQL schemas

To create or import a GraphQL schemas into Postman, complete the following steps.

  1. Under the APIs tab, click + New API, navigate to the Define tab, and then select Create new or Import file. upload schema
  2. Choose GraphQL from the dropdown, and click Save. save schema

Autocomplete for GraphQL

Once you create or import a GraphQL schema as described above, you can enable autocompletion within the GraphQL query editor.

  1. Under the Collections tab, return to your GraphQL body. Select your schema from the dropdown. You may need to refresh by clicking on the adjacent icon. schema selection
  2. Begin editing your query, and now Postman will suggest autocomplete options from the data within your GraphQL schema. autocomplete