Accessing GraphQL using API Explorer

LogScale has a built-in, interactive API explorer bundled with each installation. You can open the API explorer using a URL similar to the following in your browser:

https://$YOUR_LOGSCALE_URL/docs/api-explorer

The API Explorer is based on the GraphiQL API interface and allows for storing and recording multiple queries through a series of documents and history. This information is retained, even between different sessions within LogScale.

Note

The URL for the API explorer does not include a repository name. The LogScale GraphQL API is for accessing and changing settings on the LogScale installation, not repository data. To access repository data, use the Search API.

API Explorer

Figure 1. API Explorer


The API explorer interface is split into two main panels, the panel on the left provides an area to enter your GraphQL query or mutation, the area on the right shows the output of the mutation after it has been executed.

The buttons across the top provide the following functionality:

  • Play

    Executes the query and displays the results in the Result panel.

  • Prettify

    Reformats the query to a more human-readable format.

  • Merge

    Merges two queries when you are using fragments within to store individual query elements. Merging the queries replaces the original named fragment with in a given query.

  • Copy

    Copies the current query to the clipboard.

  • History

    Shows the history of all previous documents created within the API explorer. This will open a panel on the left that lists all previous documents and you can select a previous entry to edit or execute.

  • Introspect

    Views the corresponding GraphQL documentation for the given GraphQL fragment or interface, including showing auto-completion for the parameters and values.

  • Docs

    Provides access to the built-in GraphQL API documentation.

At the bottom of the page, the Query Variables and Request Headers panel enables you to customize the variables and request headers used for a request.

Queries that you enter and execute through the GraphiQL interface are stored and can be accessed and executed again. For infomation on running a query, see Running a Query. For information on storing and using multiple queries and the history, see Naming and Storing Multiple Queries.

Running a Query

To run a query within the API explorer:

  1. Open the API Explorer

  2. Enter a query into the query panel on the left. For example:

    graphql
    {
      dynamicConfigs {
        dynamicConfigKey
        dynamicConfigValue
      }
    }
  3. Click on the Play button at the top of the panel.

The output should be shown in the panel on the right:

Naming and Storing Multiple Queries

Multiple queries can be placed into a single document within the API explorer by naming the query or mutation. For example, two separate queries are named here:

graphql
query listLCInstallers {
  logCollectorInstallers{
    url
    architecture
    name
    type
    version
    configExample
  }
}
query getDynCfg {
  dynamicConfigs {
    dynamicConfigKey
    dynamicConfigValue
  }
}

Each query can be executed individually. When clicking Play, a popup will list each individual query.