GraphQL Requests

Applies to ReadyAPI 3.56, last modified on November 25, 2024

GraphQL requests send queries or mutations. This topic describes how to work with them in ReadyAPI. To learn more about GraphQL services, see GraphQL Testing.

You specify a GraphQL query or mutation at the top panel of the Request tab:

GraphQL support in ReadyAPI: GraphQL request

Click the image to enlarge it.

In the Query Variables panel, you specify variables. To learn how to use variables in GraphQL, see the GraphQL documentation.

Use property expansions

You can use property expansions for both variables and query or mutation. To insert a property expansion:

  1. Right-click within the editor where you want to add a property expansion and select Get Data:

    GraphQL support in ReadyAPI: Adding property expansion
  2. In Get Data, select the needed property and click Add.

  3. ReadyAPI inserts the required property expansion:

    GraphQL support in ReadyAPI: Added property expansion

Change the method

GraphQL queries support the POST and GET methods. To change the method, select it from the drop-down list at the top:

GraphQL support in ReadyAPI: Changing the method of a GraphQL request

Click the image to enlarge it.

Note: GraphQL mutations support only the POST method.

Validation

ReadyAPI can validate GraphQL requests and responses against a schema.

When you add a GraphQL schema to your project, ReadyAPI generates queries and mutations existing in the schema. All the requests under these queries and mutations, as well as test steps based on these requests, will have links to the schema, so ReadyAPI can validate if the specified query or mutation is correct:

GraphQL support in ReadyAPI: Requests generated based on GraphQL schema

Click the image to enlarge it.

ReadyAPI cannot validate requests under the manually added queries and mutations.

Validate requests

To validate a request, click Validate in the Request panel:

GraphQL support in ReadyAPI: Request validation

Click the image to enlarge it.

ReadyAPI goes through types and fields in a query and checks if the type has the specified fields.

Validate a response

To validate a response, right-click the response within the JSON panel and select Validate:

GraphQL support in ReadyAPI: Response validation

Click the image to enlarge it.

ReadyAPI checks the JSON syntax and verifies if the data the service includes in the response corresponds with the requested fields:

GraphQL support in ReadyAPI: Errors in the response

Click the image to enlarge it.

GraphQL request properties define how ReadyAPI handles specific GraphQL requests.

Testing GraphQL services in ReadyAPI: GraphQL request properties

Click the image to enlarge it.

Name Description
Name

The name of the request.

Description

An arbitrary text describing the request.

Encoding

The type of request data encoding – for example, UTF-8 or iso-8859-1. Encoding type is added as charset header.

Endpoint

The address of the GraphQL service (including the port number).

The host cannot contain underscores.
Timeout

The number of milliseconds to wait for the server response. If no data arrives within the specified time period, the request is considered to fail. If the value is 0 or is not specified, the wait time is infinite.

Bind Address

The network interface (an IP address), through which ReadyAPI will send the request.

Follow Redirects

If true, the request will follow the redirect and return the server message. Otherwise, a redirect message will be returned.

SSL Keystore

Specifies the file storing private keys that are used to authorize ReadyAPI to the server. Only works for HTTPS requests.

Dump File

The path to the file where responses will be saved. If empty, responses are discarded.

Max Size

The maximum size of responses to be saved. 0 means the entire responses will be saved.

Related Tasks

See Also

Configuring Requests

Highlight search results