Test a GraphQL API¶
The API Control Plane console includes a test console based on GraphiQL. Use it to run queries and mutations against a GraphQL API that's deployed on a gateway.
The test console loads the schema from the control plane, so it offers autocompletion even when introspection is disabled on the backend.
Before you begin¶
Deploy the GraphQL API to at least one gateway. For more information, see Deploy a GraphQL API.
Run a query¶
- Open the GraphQL API, and then select Test.
- In Gateway, select the gateway to send the request to. The console shows the Endpoint URL for that gateway.
-
In the query editor, enter a query or mutation. For example, the following query works with the sample Countries backend:
-
In the variables editor, enter the variable values:
-
If the API has an authentication policy, add the required header in the headers editor as a JSON object. Use the header that matches the policy:
The
api-key-authpolicy reads the key from theAPI-Keyheader by default:If the policy sets a different header name in its
keyparameter, use that name instead. To create a key, see Manage API keys for a GraphQL API.- Run the query. The response appears in the result pane.
The console sends every request as a POST request to the selected gateway.