SOAtest and Virtualize can make HTTP calls using the GraphQL query language, letting you retrieve specific data from multiple sources in a single call. This topic explains how to configure and use the GraphQL Client tool.

Sections include:

Resource Tab

In the Resource tab, you specify the resource to which you want to send messages by specifying a URL and query for accessing the service. URLs are specified as a literal string, which can be either a fixed or scripted value. In addition, the method to invoke can also be specified as a fixed or scripted value. 

For details about scripting values, see Extensibility and Scripting Basics.

Parameters can be set as described in Parameter Configuration. Changes made in the URL will automatically be propagated to the Path/Query table just as changes made to the Path/Query table will automatically update the URL. 

Parameter Configuration

Parameters can be configured in the Path and Query tabs.

Template Parameters

The Path tab lets you configure template parameters for the selected operation. For example, a path of "/parabank/services/bank/accounts/{accountId}" has a single path parameter: "accountId". Parameters can be fixed or scripted.

Query Parameters

The Query tab lets you configure the URL query parameters for the selected operation. You can add fixed, parameterized, or scripted values.

Encoding Note

URL query parameters are formatted according to the "application/x-www-form-urlencoded" content type. Space characters are replaced with '+'. Non-alphanumeric characters are replaced with a percent sign followed by two hexadecimal digits representing the character code. Names and values are separated by '=' and name-value pairs are separated by '&'. 

If you want to use a different format, query parameters can also be specified directly at the end of the tool’s endpoint URL (instead of in the Query Parameters section). For example, the following could also be specified as http://host:8080/path?a=1&b=2&c=3


Matrix Parameters

Matrix parameters can be configured by appending them directly to the end of the last path segment in the resource URL. For example, the following parameter could also be specified as http://host:8080/path;jsessionid=12345

Query Tab

The Query tab allows you to specify the GraphQL query for the message that will be sent.

Before you specify the query, be sure to select a media type supported by your GraphQL service from the Content-Type drop-down list. The request structure will be transformed at runtime based on this selection. The available options are:

Content TypeHTTP MethodRequest Structure
application/jsonPOST
HTTP body is a JSON object of the form:
{
  "query": "...",
  "operationName": "...",
   "variables": {
       "myVariable" : "..."
       }
}
application/graphql+jsonPOSTSame as "application/json" above.
application/graphqlPOSTQuery sent in HTTP body. Variables and operation name sent in query string.
application/x-www-form-urlencodedPOSTQuery, variables, and operation name sent as URL-encoded string in HTTP body.
N/AGETQuery, variables, and operation name sent as parameters in query string.

You can then select either Literal or Scripted from the Input Mode drop-down list and choose either the Text or File option. The Text option enables you to manually add your script in a text input field while the File option allows you to browse for an external script file that will be executed when the tool is called.

Specify the name of the operation to be sent at runtime in the Operation Name field. This is particularly important if the query contains multiple operations.

Add any variables declared in the query in the Variables table.

HTTP Options Tab

The HTTP options allow you to determine which protocol (HTTP 1.0 or 1.1) is used to send the request, as well as various options related to the protocol (security, headers, cookies, etc.). 

Select the appropriate protocol from the Transport drop-down list, then configure its properties, which are described in the following sections:

SOAtest

Misc Tab

The following options are available in the Misc tab:

  • Valid HTTP Response Codes: Allows you to customize the tool behavior so that it succeeds with HTTP response codes outside the 2xx range. Specify single codes and/or code ranges as a comma-separated list. For example, if you use "302, 500-599", a 302 code or any code in the 5xx range will be accepted.  If you're using a parameterized value, be sure that the value in the data source uses this same format (e.g., "302, 500-599").
  • Timeout after (milliseconds): Specifies the length of delay (in milliseconds) after which your FTP, telnet, or HTTP requests should time out. The Default setting corresponds to the timeout set in the Preferences panel. The Custom setting allows you to enter a timeout. A non-positive timeout value can be entered to specify an infinite timeout.

    • Fail the test on timeout: Select this option if you want the tool to fail on the specified timeout.
    • Pass the test only if a timeout occurred: Select this option to have the tool pass if the specified timeout occurs (i.e. the test does not finish execution within the specified time).
  • Outgoing Message Encoding: Choose Custom from the drop-down menu and choose an encoding for the outgoing message. The default is to use the encoding configured in the immediate parent test suite (see Specifying Client Options). You can also specify this option globally in the Parasoft Preferences Misc settings (see Additional Preference Settings ).


  • No labels