Test GraphQL APIs with GraphQL Explorer

  • リリースバージョン: Australia
  • 更新日 2026年03月12日
  • 所要時間:3分
  • Test query your GraphQL APIs using an integrated GraphQL testing tool.

    始める前に

    Create a schema for your GraphQL API. For more information, see Create a GraphQL schema.

    Enabling introspective queries allows GraphQL Explorer to show the schemas on the instance in the Documentation Explorer and as auto-complete suggestions, which makes finding queries and mutations easier. For more information, see Enable introspective queries for GraphQL schemas.

    注:
    Don’t use introspective queries in a production environment.

    Role required: graphql_schema_admin or admin

    このタスクについて

    The GraphQL Explorer integrates the GraphiQL IDE into the ServiceNow AI Platform. For additional information about the interface, see the GraphiQL readme in the GraphiQL GitHub repository.

    手順

    1. Navigate to All > System Web Services > GraphQL > GraphQL Explorer.
    2. オプション: If you enabled introspection, in the left sidebar, select the Show Documentation Explorer icon (Show Documentation Explorer icon) to view and search for available queries or mutations.
    3. In the editor, enter a query to the schema.

      Include both the application and schema namespaces in the query. For information about directives you can apply, see Directives and global functions.

      This example shows using both the application and schema namespaces:
      • Application namespace: x_graph_scope
      • Schema namespace: planet
      query {
        x_graph_scope {
          planet {
            findAll {
              name
              mass
              distance
            }
          }
        }
      }

      This example shows using the @defer directive to stream results for the openedBy field after the initial incident response.

      query findIncidents {
        now {
          incident {
            findAll {
              description {
                displayValue
              }
              ...
              @defer(label: "my-label", if: true) {
                openedBy {
                  firstName
                  lastName
                }
              }
            }
          }
        }
      }
    4. オプション: At the bottom of the editor, select Variables and enter any necessary variables.
    5. Select the Execute query icon (Execute query icon).
      ヒント:
      You can also use a keyboard shortcut. To see the list of available keyboard shortcuts, select the Open short keys dialog icon (Open short keys dialog icon).
      The result of your query returns in the right pane.
    6. オプション: Select the Add tab icon (Add tab icon) to run additional queries.

    次のタスク

    If you need to view a list of previous queries, in left sidebar, select the Show History icon (Show History icon).

    To access record data in a component, you can create a custom component and query your scripted GraphQL schema from the component. For more information, see Query a GraphQL schema from a component.