API testing in Postman using GraphQL

GraphQL is an open source data query and manipulation language for APIs, a query language and runtime for APIs. It enables clients to precisely specify their data needs and obtain predictive results. GraphQL is designed to improve the efficiency, flexibility, and reliability of APIs.

Postman is a powerful tool for API development, it supports REST and GraphQL API. Postman also provides a user-friendly interface for building, testing, and documenting APIs.

In this article, we'll cover how to use GraphQL for Postman testing. The following are the detailed steps:

Using GraphQL with Postman

Import the GraphQL schema

1. Select "APIs" in the left navigation bar and create a new API.

2. Select GraphQL from the Schema Type drop-down list.

3. Select GraphQL SDL from the Schema Format drop-down list.

 4. Enter the GraphQL schema in the editor and save it.

 

Send GraphQL query in Body

1. Create a new request in Postman and enter the GraphQL endpoint URL in the address field.

2. Select POST from the Request Method drop-down list.

3. Under the Body tab, select the GraphQL body type.

4. Enter the GraphQL query in the query editor.

 

Using the GraphQL content-type header

1. Create a new request in Postman and enter the GraphQL endpoint URL in the address field.

2. Select POST from the Request Method drop-down list.

3. In the Headers tab, add Content-type of application/graphql.

4. Under the Body tab, select the raw type, select Text from the format drop-down list, and use the standard GraphQL format to build a query in the body. Click the Send button to send the request, and then view the response result.

 

use variables

You can create a JSON-formatted schema, assign values ​​to variables, and avoid having to enter parameters in the query string. Modify the body in the "QUERY" section to dynamically assign the value of the variable, edit the "GRAPHQL VARIABLES" section with whatever we want the variable to be set to.


 The following are the better learning tutorial resources I have collected. Although they are not very valuable, if you just need them, you can leave a message in the comment area [777] and just take them away

Friends who want to get information, please like + comment + favorite , triple!

After three times in a row , I will send you private messages one by one in the comment area~

Guess you like

Origin blog.csdn.net/m0_70618214/article/details/132259770