Applying the GraphQL schema to a message
When you are testing a GraphQL endpoint you can apply the GraphQL schema and other formatting options to messages in your tests.
Before you begin
- Created an HTTP connection as a logical resource. See Creating logical HTTP connections.
- Created a physical web server resource and bound it to the logical connection. See Creating physical web server resources.
- Created a service component. See Creating a service component.
- Created an operation. See Creating an operation.
- Created tests by using message exchange pattern. See Creating a single test by using MEP. For example, you might have created a test for the Request-Reply MEP.
- Opened the test in the Test Factory perspective that displays the test steps in the MEP test.
Procedure
-
Click the Send Request test step.
A message is displayed in the message editor.
-
Right-click text (String) in the
Message field, and then click
Schema.
The Schema Selector dialog box is displayed.You can select the schema from the following options:
Schema option Action GraphQL Select this schema option if you want to use the built-in GraphQL schema either as the GraphQL mutation or GraphQL query operation type in the messages. GraphQL Schema Select this schema option if you have downloaded other GraphQL schemas and you do not want to use the built-in schemas. Note: Both GraphQL schema options can be used to create messages that contain multiple queries or mutations. -
Click the Schema Type field in the
Schema Selector dialog box,
and then select the schema option as follows:
- Click to use the built-in GraphQL schema.
- Click Rational® Integration Tester. to use the GraphQL schema you have imported into
The GraphQL schemas that you can apply to the message are displayed.
-
Select a GraphQL schema document from the list.
You can select from the following options:
- mutationDocument
- queryDocument
You can find the schemas that are applied when you select any of the document type as displayed in the following table:Document type When GraphQL is selected When GraphQL Schema is selected mutationDocument queryDocument -
Expand the Formatter
Properties section, if it not already
expanded, and perform the action listed in the
following table:
Note: The settings that are displayed with the default options are as set in the project preferences. You can either retain the default settings or change the settings.
Option Description Action Style
The options available are as follows:- JSON Payload
- GraphQL Payload
- Query Parameters
The preference setting that are applied to messages that use the GraphQL schema.
The default option is JSON Payload.
The default option can be changed from the project preferences settings in
.Select the style that you want: - Select JSON Payload if the message body is to be displayed and sent as a JSON encoded string.
- Select GraphQL Payload if the message body is to be displayed and sent in the GraphQL format.
- Select Query Parameters if the content of the message is to be sent as URL encoded query parameters and the message body is empty.
Payload Pretty print JSON/GraphQL
When selected, the JSON data or GraphQL data is formatted with proper indentation and line feeds that enhances the display to be pretty. Select the option or retain as unselected. URI This option is enabled only when you select Query Parameters as the preference setting in the Style field. The URI prefix replaces the Resource Path in the base URL in the message headers.
Enter the URI prefix in the URI prefix field.
-
Expand the Content
Options section, if it is not already
expanded and select your action from the following
options.
Note: The check box for the options to Retain existing content, Include Text nodes, or Include optional nodes can be either selected or cleared based on the default action set in .
Option
Description
Action
Retain existing content
When this option is selected, you can apply a schema or expand a field without losing the original data in the messages.
When this option is not selected, existing data is cleared before the new schema is applied.
In cases where the data is assumed to be retained, this option is not displayed.
Retain the selection or clear the selection.
Include Text nodes
When this option is selected, you can generate Text nodes with the message.
When this option is not selected, the text nodes do not appear.
Retain the selection or clear the selection.
Include optional nodes
When this option is selected, you can select and add the optional fields that the schema includes in the message.
When this option is not selected, you cannot add any optional fields.
Retain the selection or clear the selection.
-
Click OK to save your settings and close
the Schema Selector dialog box.
The completed message is displayed.
Results
You have applied the GraphQL schema to a text message.