GraphQL APIs

Applies to ReadyAPI 3.57, last modified on December 20, 2024

When you add a GraphQL API, ReadyAPI shows its parts in the Navigator panel:

GraphQL API Structure

Click the image to enlarge it.

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:

GraphQL API overview

Click the image to enlarge it.

Endpoints

The Endpoints page is the central place where you manage endpoints used in the GraphQL API.

Testing GraphQL APIs in ReadyAPI: The Endpoints page

Click the image to enlarge it.

You can configure the following options:

Option Description

Endpoint

The endpoint URL or destination.

The host cannot contain underscores.

Environment

An environment associated with the endpoint.

You can create only one endpoint associated with each environment. When you add a new endpoint associated to the same environment, the new endpoint will overwrite the existing one.
No Environments should be selected if you need to hit different endpoints in the same test case. The base API will remain the same, but will also allow for flexibility when configuring the requests contained in the functional tests.

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:

Testing GraphQL APIs in ReadyAPI: Set endpoins without environments

Click the image to enlarge it.

When you set an environment, all the API requests and test steps will use the endpoint associated with this environment:

Testing GraphQL APIs in ReadyAPI: Set endpoins with environments

Click the image to enlarge it.

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.

Testing GraphQL services

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 Plusnext to the Queries or Mutations node:

    Show image

    — or —

    Right-click the Queries or Mutations node in the Navigator and select New GraphQL Query or New GraphQL Mutation:

    Show image

Add GraphQL request

To add a GraphQL request:

  • In the Navigator, click Plusnext to the query or mutation to which you want to add a request:

    Show image

    — or —

    Right-click the query or mutation node in the Navigator and select New Request:

    Show image

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

  1. Right-click the request in the Navigator panel and select Add to Test Case

    Show image

    – or –

    Open the request editor and click Add to Test Case.

    Show image

  1. In the test case editor, select the GraphQL Query Request or GraphQL Mutation Request test step from the toolbar.

    Show image

    – or –

    Click in the navigator and select the SOAP Request test step from the APIs and Connections section.

    Show image

    Tip: Use the Search field to filter test steps.
  1. ReadyAPI shows the Add Request Test Step dialog:

    SOAP testing in ReadyAPI: Add SOAP Request test step dialog

    Click the image to enlarge it.

    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:

  1. Click next to the service and select Generate Test Suite from the flyout menu.
    –or–
    Right-click the service and select Generate Test Suite.

  2. Use the Generate Test Suite dialog to configure how ReadyAPI should create test cases:

    Generate Test Suite dialog
    • 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.

  3. Click OK.

ReadyAPI will create new test cases and name them based on the definition.

See Also

GraphQL Testing
GraphQL Requests

Highlight search results