Accessing GraphQL with API Explorer

LogScale has a built-in, interactive API explorer bundled with each installation. It allows you to execute GraphQL queries and mutations in the browser using a URL that looks something like the following: https://$YOUR_LOGSCALE_URL/docs/api-explorer

The URL shown doesn't include a repository name because it's for accessing and changing settings on a LogScale installation itself, not repository data. For that, use the Search API.

The API Explorer can be useful in learning GQL and for testing before incorporating functions into your code. However, changes you make will effect LogScale: you're changing the actual administrative data. Below is a screenshot showing how the API Explorer looks in a browser:

Screenshot showing the GraphQL API Explorer interface with a split panel layout: the left panel contains a GraphQL query editor with sample queries for getting information on repositories; the right panel displays the results from running one of the queries

Figure 1. API Explorer


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

Layout

The API explorer interface is typically split into two main panels. The panel on the left provides an area to enter GraphQL queries or mutations. The right, possibly middle, panel will show the results after execution of a function, including error messages when unsuccessful. You can see this layout in the screenshot above.

Other panels and dialog boxes will be visible depending on the button selection. These buttons are situated in four main areas:

Middle Buttons

Along the middle, between the two main panels is a set of buttons. They're related to the query or mutation you may be entering in the left panel.

  • Play: When this button (i.e, â–º) is clicked, it will execute the query or mutation in the left panel. The results will then appear in the right panel, which will be in a json format.

    You can add labels so that you may enter multiple functions. Labels are given immediately after the text query or mutation. You can see examples of this in the screenshot here: all_repos and one_repo. With labels, when you click on the Play button, a box of your choices will appear (see screenshot). You would then click on the one you want to execute and its results should appear in the right panel.

  • Prettify: This button (i.e., an icon of a broom), when clicked will reformat the query or mutation you entered to a make it more easily readable. It will add hard-returns, indent text and may remove extra spaces. This has no effect on the results, though.

  • Merge: Use this button (i.e., an icon of an X encased in square-brackets) to merge two queries or mutations when you're using fragments within to store individual elements. Merging them replaces the original named fragment within a given function.

  • Copy: This simply copies the current query or mutation to the clipboard. You can then paste it elsewhere, such as into your code using a text editor.

Left Margin Buttons

There other buttons to the left of the first panel, some near the top and other near the bottom. Below are explanations of them:

  • Documentation: This button, a book icon, will open a third panel on the right. It will show the built-in documentation — not the documentation you're reading now. It will reveal the embedded documentation relevant to whatever query, mutation, datatype, or field you've clicked on. It contains very brief and succinct documentation for quick reminders of how to enter functions and data.

  • History: This button, the icon of a clock turning backward, will show the history of all previous queries and mutations you executed within the API Explorer. Clicking on it will open a panel on the left that lists all them so that you can re-run them or copy them.

  • Re-Fetch GQL Schema: The GraphQL API Explorer operates in accordance with an underlying copy of the scheme.graphql file. When you type in a query or mutation, you're prompted with auto-completion choices. It uses the schema file for ensuring compliance with the syntax, and it gives you choices for enumerated datatypes.

    When using LogScale on a self-hosted installation, you may need to refresh the schema file to be able to access the latest functions and parameters. You would do this by clicking on the icon of a pair of circular arrows. This isn't generally necessary on CrowdStrike cloud hosted instances, but may be used to get the latest changes for the day.

  • Short-Keys: This button, represented by the Mac command-key icon in the screenshot above, when clicked merely displays a box listing the shortcut key combinations available.

  • Settings: There are a couple of settings that can be made in the dialog that appears when you click this button (i.e., the cog icon). One will clear all the locally stored data.

Top and Bottom

There are two more sets of buttons or links of which you should be aware: one or two at the top, and a couple at the bottom, below the first panel.

  • You may notice that at the top of the first panel that it has a tab and that there's a plus-sign to the right of it. You can click on that plus-sign to add another tab, another left panel for entering more queries and mutations. This can be an alternative to using labels — or you can do both, use labels and use multiple tabs.

  • At the bottom of the page, below the left panel, clicking on Query Variables and Request Headers opens a pair of bottom panels. They will allow you to customize the variables and request headers used for a request.