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.

    New API
  2. Enter a name and version for your API.

  3. Choose GraphQL from the Schema type dropdown list.

  4. Choose either JSON or GraphQL SDL from the Schema Format dropdown list.

  5. You can optionally select the Import tab to import an API specification directly from either a local file or a GitHub or Bitbucket repo. If you don't import a schema, Postman will populate your API with a sample specification you can edit at any time.

  6. Click Create API.

  7. Open the new API's version page, and navigate to the Definition tab to edit your 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 list. You may need to refresh by clicking on the adjacent icon.

schema selection

  1. Begin editing your query, and now Postman will suggest autocomplete options from the data within your GraphQL schema.