Enterprise Hubs only
This document does not apply to rapidapi.com.
This example will guide you through creating a test that uses the GraphQL Platform API to determine the number of public APIs in your hub and only succeed if it is a specific number. An example use case would be determining if a test was made public or private on accident by a member of your organization.
- Start by creating a new test, in this example, we have named the test "Number of public APIs"
- Add an HTTP Post step, the URL for this step will be your GraphQL Platform API URL. This can be located by searching for "GraphQL Platform" in your hub and viewing it in the playground.
- Enter a variable name for the API response, in this example, we have named the variable "publicAPIsresponse" (example below)
- In the Headers tab of the Post step, enter the following:
- Content-Type: application/json
- X-RapidAPI-Key: (This can be located by searching for "GraphQL Platform" in your hub and viewing it in the playground)
- X-RapidAPI-Host: (This can be located by searching for "GraphQL Platform" in your hub and viewing it in the playground)
- X-RapidAPI-Identity-Key: (This can be located by accessing a public API in your hub and viewing it in the playground)
- In the Body tab of the Post step, change the type to
graphqland enter the query located here.
- In the Body tab of the Post step, click the + button under
Variablesto create a new variable. Name the variable
visibilityand set the value to
Optional Create an Assert Equals step to ensure that you get a status of 200 from your request. (example below)
Create a Set Variable step to set the number of Public APIs returned from your request.
You can determine the request's structure by inspecting it in an execution report. Since the value of the number of public APIs is returned in the
response's data, in an object called
data, and then in a secondary object called
apis, and lastly, in a field with the name
totalCount, we will need to point to this in the key field we of this step.
In this example, we created a variable named
numberOfPublicAPIs (example below).
Create an Assert Equals step to ensure that the value of the
numberOfPublicAPIs variable is the number of public APIs you are expecting (example below).
Congratulations, you have just created a test to verify the number of public APIs on your hub. You may want to set this test to run on a schedule, for example, every 24 hours, with alerts to ensure that you are aware of a change in the number of public APIs within a day.
Updated about 1 month ago