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

You must have completed the following tasks:

Procedure

  1. Click the Send Request test step.

    A message is displayed in the message editor.

  2. Right-click text (String) in the Message field, and then click Schema.
    Image showing selecting the 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.
  3. Click the Schema Type field in the Schema Selector dialog box, and then select the schema option as follows:
    Image showing the different GrqphQL schema types
    • Click Web > GraphQL to use the built-in GraphQL schema.
    • Click Web > GraphQL Schema to use the GraphQL schema you have imported into Rational® Integration Tester.

    The GraphQL schemas that you can apply to the message are displayed.

  4. 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 schema for graphql mutation schema for graphql schema mutation
    queryDocument schema for graphql query schema for graphql schema query
  5. Expand the Formatter Properties section, if it not already expanded, and perform the action listed in the following table:
    image of the formatter properties options
    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 Project > Preferences > GraphQL.

    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.

  6. Expand the Content Options section, if it is not already expanded and select your action from the following options.
    image of the content 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 Project > Preferences > Message.

    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.

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