API Gateway 10.15 | Getting Started with API Gateway | Create your first GraphQL API | Testing a GraphQL API using Postman
 
Testing a GraphQL API using Postman
You must assess the GraphQL API created is working as expected before exposing it to the API consumers. You should verify the correct status code of the response. For instance, successful HTTP requests should return 200 OK, creating a resource should return 201 CREATED, and so on.
Let’s test the Starwars GraphQL API, which was imported using a file. In this example, to test whether the Star Wars API is created successfully, let’s retrieve all the films in the Star Wars franchise using the Starwars API. The API response should list all the films in the Star Wars franchise.
Before you begin
Ensure that you have:
*Postman installed in your system, or you can you use the web version of Postman.
*Downloaded the sample Star Wars Postman collection GraphQL.postman_collection.json from the Github repository https://github.com/SoftwareAG/webmethods-api-gateway/tree/master/gettingstarted/graphql.
1. Open Postman.
2. Click Import.
test graphql api step1
3. Select GraphQL and select the GraphQL.postman_collection.json file from your local folder.
4. Click Import.
5. Open the imported GraphQL API collections and select Starwars API GW.
test graphql api step 2
6. Select a method. For example, select the method as POST.
7. Specify the request URL. For example, provide the Star Wars endpoint from the API you created.
test graphql api step 3
8. Set the request body type as GraphQL
test graphql api step 4
9. Pass the query in the QUERY section. For example, write a query to fetch a list of all the films in the Star Wars franchise.
test graphql api step 5
10. Click Send.
The GraphQL API is invoked successfully and returns the status code as 200 OK HTTP. The response lists all the films in the Star Wars franchise.
test graphql api step 6
The API is tested and working as expected. You can now expose the API to the consumers.
For details about the further actions you can perform on the API, see All about APIs in the API Gateway User's Guide.