GraphQL Requests

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 request editor

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

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 step 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

Important

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

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

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

GraphQL request properties

GraphQL request properties define how ReadyAPI handles specific GraphQL requests.

Testing GraphQL services in ReadyAPI: GraphQL request properties

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).

Important

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 response will be saved.

Related Tasks

go.gifCreate Functional Tests From API Definition

go.gifAdd Request to Test Case

go.gifAdd Authentication

go.gifUse Environments

See Also

Publication date: