You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

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 menu. 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 Form GraphQL, Literal, or Scripted from the Input Mode menu and choose either Text or File. 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.

The order of queries and field selections might be altered when converting the payload from Literal to Form GraphQL. If the order of the queries needs to be preserved, you should work in Literal mode.

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, and so on). 

Select the appropriate protocol from the Transport menu, then configure its properties, which are described in the following sections:

SOAtest

Virtualize

Internal Transport for Client Tools

Clients chained to responders can route messages to virtual assets on the local server without consuming an HTTP connection by using localhost, 127.0.0.1, or the special host name host.virt.internal. When using localhost or 127.0.0.1, the specified port must match the port Virtualize is deployed on; when using host.virt.internal the port is not used. For example, a virtual asset deployed on http://localhost:9080/myVirtualAsset can also be reached by a chained client using http://host.virt.internal/myVirtualAsset.

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 (for example, "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 (that is, the test does not finish execution within the specified time).
  • Outgoing Message Encoding: Choose Custom from the 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