In this section:

Introduction

You can specify how you want to enter messages from the Input Mode menu in message tools and responders like Request, Response, and Payload. The Form GraphQL input mode provides a tree view of the GraphQL message so that you can construct and review GraphQL messages in a graphical interface. This mode is a GraphQL-focused version of the Form Input mode.

GraphQL Messages Constrained to an SDL

You can constrain your GraphQL message to a schema definition by linking it to an SDL. To build a GraphQL message constrained to an SDL:

  1. Enter the URL or location of the SDL in the SDL field. You can also click Browse to navigate to an SDL file.
  2. Enable Constrain to SDL.
  3. Choose Form GraphQL from the Input Mode menu.

If the SDL is updated, return to this screen and click Refresh SDL to update the constraints for the GraphQL message.

When constrained to an SDL, you will be limited in what elements you can use when building out your tree according to the schema. How you add them depends on their type:

Queries, Mutations, and Subscriptions

Select the top-level node ( {} ) and click Insert for either the Query, Mutation, or Subscription table.

Fields

Fields can be added to operations, fragments, or other fields, as specified by the SDL. To include a field:

  1. Select the SelectionSet of the operation, field, or fragment to which the new field is to be added.
  2. Enable the field you wish to include. Doing so will create a new node for the field.
  3. Select the field node to edit it.

Arguments

Arguments can be added to fields or directives. Required arguments, as specified by the SDL, are automatically included. Optional arguments are not automatically included. To include an optional argument:

  1. Select the desired argument node under the field or directive.
  2. If the SDL indicates the argument may be null, it will have a null option. When enabled, the value will be null. Disable it to assign a non-null value to the argument.
  3. Select the argument node to edit it.

Arguments can be converted into variables. To do so, right-click the desired argument node and choose Switch to Variable Reference.

Directives

Directives can be added to operations, fragments, fields, or variables, as specified by the SDL. To include a directive:

  1. Select the operation, fragment, field, or variable to which the new directive is to be added.
  2. Enable Directives if it is not already enabled. Doing so will create a Directives node.
  3. Select the Directives node and enable the directive you wish to include. Doing so will create a new node for the directive. If the directive has additional settings, you can select its node to edit it.

Variables

Variables can be added to operations. To add a variable:

  1. Select the operation to which the new variable is to be added.
  2. Click Insert under the Variables table. Doing so will create a new variable.
  3. Select the variable node to edit it.

To remove a field, argument, or directive, select its parent node and uncheck it. To remove a variable, select it in the Variables table and click Delete.

Unconstrained GraphQL Messages

You can build an unconstrained GraphQL message manually or, if you have a GraphQL message available, use it to build your Form GraphQL. To do so, paste your GraphQL message into the Literal view, then switch to Form GraphQL view. The Form GraphQL view will automatically be populated with the provided values and show a graphical representation of the message.

You can add new GraphQL operations from the form view. Select the top-level node ( {} ) and click Insert for either the Query, Mutation, or Subscription table.

Whether you pasted a GraphQL message into the Literal view and converted it to Form GraphQL view or added an operation manually, you can add and remove fields, arguments, directives, and variables from the form view as well.

Fields

Fields can be added to operations or other fields. To add a field:

  1. Select the operation or field to which the new field is to be added.
  2. Enable SelectionSet if it is not already enabled. Doing so will create a SelectionSet node. If it is already enabled, skip to the next step.
  3. Right-click the SelectionSet node and choose Insert.
  4. Enter a name for the new field and click OK.

Arguments

Arguments can be added to fields or directives. To add an argument to a field:

  1. Select the field to which the new argument is to be added.
  2. Enable Arguments if it is not already enabled. Doing so will create a Arguments node. If it is already enabled, skip to the next step.
  3. Right-click the Arguments node and choose Insert.
  4. Enter a name for the new argument and click OK.

To add an argument to a directive:

  1. Right-click the directive to which the new argument is to be added and choose Insert.
  2. Enter a name for the argument in the dialog that opens and click OK.

Directives

Directives can be added to operations, fields, or variables. To add a directive:

  1. Select the operation, field, or variable to which the new directive is to be added.
  2. Enable Directives if it is not already enabled. Doing so will create a Directives node. If it is already enabled, skip to the next step.
  3. Right-click the Directives node and choose Insert.
  4. Enter a name for the new directive and click OK.

Variables

Variables can be added to operations. To add a variable:

  1. Select the operation to which the new variable is to be added.
  2. Click Insert under the Variables table. Doing so will create a new variable.
  3. Select the variable's node and enter a name and a type for it.

To remove a field, argument, or directive, right-click the node and choose Delete. To remove a variable, select it in the Variables table and click Delete.

Editing Values

You can specify values using the fixed, parameterized, auto, and script options available across the various tree views.

Note that Form Input options which are applicable to GraphQL are available from this view (with relevant terminology changes, such as null vs nil). This includes populating the entire tree with values in a data source, generating a CSV data source template, replacing specific elements with data source values, and so on. For details, see Form Input.

Viewing the Literal GraphQL

Switching to the Literal view will apply the contents of Form GraphQL to the Literal view. Right-clicking GraphQL messages in the Literal view allows you to automatically "beautify" the GraphQL.

  • No labels