When you add a GraphQL API, ReadyAPI shows its parts in the Navigator panel:
This section describes how you can manage GraphQL APIs in ReadyAPI. To learn basic information on testing GraphQL services in ReadyAPI, see GraphQL Testing.
GraphQL service
A GraphQL service is a top-level node of the GraphQL services in the Navigator panel. Select it to see and modify added queries, mutations, endpoints, and the service’s schema:
Endpoints
The Endpoints page is the central place where you manage endpoints used in the GraphQL API.
You can configure the following options:
Option | Description | ||||
---|---|---|---|---|---|
Endpoint |
The endpoint URL or destination.
|
||||
Environment |
An environment associated with the endpoint.
|
||||
Authorization Profile |
An authorization profile used to access the endpoint. |
Work with environments
When you do not use an environment, you can assign any endpoint that is not associated with an environment to GraphQL API requests. In this case, the request or test step will send a request to the specified endpoint. Once you change the endpoint, it will be updated in all the requests and test steps using it:
When you set an environment, all the API requests and test steps will use the endpoint associated with this environment:
Specification
The Specification page shows the GraphQL schema: defined types, queries and mutations. This information helps you build queries and mutations.
To quickly navigate through the schema, use the navigation tree on the left.
GraphQL queries and mutations
Queries and mutations are grouped in the Navigator under the nodes with the same names: Queries and Mutations.
For each query and mutation, you create one or more requests, each of them may fetch a different set of data from the service or specify different parameters for mutations.
Add query or mutation
To add a query or a mutation:
-
Click next to the Queries or Mutations node:
— or —
Right-click the Queries or Mutations node in the Navigator and select New GraphQL Query or New GraphQL Mutation:
Add GraphQL request
To add a GraphQL request:
-
In the Navigator, click next to the query or mutation to which you want to add a request:
— or —
Right-click the query or mutation node in the Navigator and select New Request:
To learn more about GraphQL requests, see GraphQL Requests.
Organizing GraphQL services
You can reorganize elements of the GraphQL API: queries, mutations, and requests.
Renaming items
To rename an item:
-
Select it in the Navigator panel and press F2.
– or –
-
Right-click it in the Navigator panel and select Rename.
Renaming items does not affect the API definition, it affects only the item representation in ReadyAPI.
Renaming the service in a composite project will change the matching folder name. |
Deleting items
To delete an item:
-
Select it in the Navigator panel and press Shift+Delete.
– or –
-
Right-click the item in the Navigator and select Delete.
Request-specific tasks
Adding requests to functional tests
-
Right-click the request in the Navigator panel and select Add to Test Case
– or –
Open the request editor and click Add to Test Case.
-
In the test case editor, select the GraphQL Query Request or GraphQL Mutation Request test step from the toolbar.
– or –
Click in the navigator and select the SOAP Request test step from the APIs and Connections section.
Tip: Use the Search field to filter test steps.
-
ReadyAPI shows the Add Request Test Step dialog:
In the dialog, you select the base request and the target test case to which you want to add the new test step. Additionally, you specify the Valid HTTP Status Code and Valid Response SLA assertions.
Copying requests
In ReadyAPI terms, cloning means creating an exact copy of an item. To clone test steps, test cases, or test suites:
-
In the Navigator panel, press Ctrl and drag the desired test step, case, or suite to a new location.
– or –
-
Right-click the request and select Clone Request.
Generate test suites
To create a test suite and test cases based on the service definition, do the following:
-
Click next to the service and select Generate Test Suite from the flyout menu.
–or–
Right-click the service and select Generate Test Suite. -
Use the Generate Test Suite dialog to configure how ReadyAPI should create test cases:
-
Test Suite – Specifies the test suite to which the created test cases will be added.
-
Style – Specifies how ReadyAPI organizes the created test cases:
-
One test case for each resource – ReadyAPI creates REST Request test steps for each method in the selected resources and organizes them into several test cases.
-
Single test case with one request for each method – ReadyAPI creates REST Request test steps for each method in the selected resources and organizes them into a single test case.
-
-
Queries – Selects queries to generate test cases.
-
Mutations – Selects mutations to generate test cases.
-
Create Load Test – Specifies whether ReadyAPI creates a load test for each created test case.
-
-
Click OK.
ReadyAPI will create new test cases and name them based on the definition.