This
This
What is GraphQL?
GraphQL is a data query and manipulation language for application programming interfaces (APIs) and a server-side runtime for executing queries and mutations with your data. It lets you define the exact data that you want to fetch from the API and, unlike REST, enables you to retrieve data from multiple sources in a single query.
GraphQL—sometimes abbreviated "GQL"—has two main operation types that are used in SL1:
- Queries, which read and return data
- Mutations, which write and modify data
Typically used over HTTP, GraphQL lets you make a POST request using a JSON structure to an HTTP endpoint on your server; the server then processes the request, calls the database or other source to fetch the requested data, and then returns the data to you in the same JSON structure as your request.
GraphQL is data source-agnostic. This means it can query data from any source: Databases, REST APIs, microservices, flat files, or even other GraphQL servers.
For more information about GraphQL, see the GraphQL documentation.
How Does SL1 Use GraphQL?
The SL1 GraphQL API allows external systems to programmatically access data in SL1 using the GraphQL query language. The API gives access to entities in the platform, such as devices and collected data, using standard HTTP request/response protocols.
The default SL1 user interface, also referred to as "AP2", uses GraphQL exclusively to request and access SL1 data from multiple sources and consolidate it together into a unified JSON response. The default SL1 user interface does not make any REST API calls.
Authentication and User Access
The SL1 GraphQL API uses the same authentication profiles and credentials as SL1. When you log in to SL1, you are also authenticated in the SL1 GraphQL API. It does not require an additional login.
All users have access to the SL1 GraphQL API—not only administrators—but users' ability to perform actions in GraphQL is controlled in the same way as in other parts of SL1:
- A user can interact only with entities associated with their organizations. Entities are either explicitly aligned with organizations, aligned with organizations based on the user that created the entity, or are not aligned with an organization.
- Administrator users can perform all actions on all resources, regardless of organization membership.
- A user must be granted the appropriate access keys to interact with specific parts of SL1 or perform specific actions in SL1.
Using Request Headers
Using a request, or "run-as", header allows you to run your query as another user when it is passed to the GraphQL API. The X-sl-run-as header is only available for use as an administrator; other users attempting to use it will receive a 404 error. To use the X-sl-run-as header you must set the value of the header to the user you want to run as.
The GQL Browser
To explore and perform operations in the SL1 GraphQL API, you can use one of the following options, depending on which version of SL1 you are using:
- The GQL Browser page (System > Tools > GQL Browser) is a page built into SL1 versions 12.3.0 and later.
- GraphiQL is a browser-based user interface that is used in SL1 versions 12.2.x and earlier. To access the GraphiQL interface, type the URL or IP address for SL1 in a browser, add /gql to the end of the URL or IP address, and press .
GraphiQL is not maintained by ScienceLogic. You can access its documentation at https://github.com/graphql/graphiql.
Both of these methods use similar elements that enable you to interactively explore the capabilities of, and execute queries against, the SL1 GraphQL API. Unlike the SL1 REST API, all requests to the GraphQL API on a given SL1 system use the same URI.
For more information about using the GQL Browser or GraphiQL, see the