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.
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.
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.
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
To create or import a GraphQL schemas into Postman, complete the following steps.
Under the APIs tab, click + New API.
Enter a name and version for your API.
Choose GraphQL from the Schema type dropdown list.
Choose either JSON or GraphQL SDL from the Schema Format dropdown list.
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.
Click Create API.
Open the new API's version page, and navigate to the Definition tab to edit your schema.
Once you create or import a GraphQL schema as described above, you can enable autocompletion within the GraphQL query editor.
- 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.
- Begin editing your query, and now Postman will suggest autocomplete options from the data within your GraphQL schema.