Query GraphQL schema metadata
List the datasets a GraphQL API endpoint serves, the fields of each dataset, and their types with an introspection query.
You can ask the GraphQL API which datasets an endpoint serves, which fields each dataset returns, and the type of each field. The answer comes from an introspection query, which reads the schema instead of your data. Use it to check a dataset or field name before you write a query.
Prerequisites
- A personal token. To create one, refer to Manage a personal token.
List datasets and their fields
Each endpoint describes only its own datasets. The steps below query https://api.azion.com/v4/metrics/graphql, which serves the metrics datasets. To list the datasets of another endpoint, such as https://api.azion.com/v4/events/graphql, send the same queries there.
To read the schema of the metrics endpoint:
Send this query in a POST request to https://api.azion.com/v4/metrics/graphql, with the header Authorization: Token [TOKEN VALUE]. To send a query, refer to GraphQL API quickstart or Run GraphQL queries in Postman.
The API answers with HTTP 200 and one entry per dataset in fields. The response below is cut after the third dataset, and after the third field of each dataset:
The first query leaves out deprecated datasets, such as httpMetrics, which workloadMetrics replaces. To list every dataset with its deprecation status, send this query to the same endpoint:
The API answers with HTTP 200. The response below is cut after the third dataset:
You have the name, description, and field list of each dataset the endpoint serves, and the replacement of each deprecated one.
Read the response
Each key of the two responses describes one part of the schema:
| Key | What it holds |
|---|---|
name | Query, the root type that holds every dataset of the endpoint. |
description | The description of the root type. It is null. |
fields[].name | The name of a dataset, the name you put in a query. |
fields[].description | What the dataset holds. Most descriptions also name the time buckets the dataset groups data into, such as minute, hour, and day. |
fields[].type.ofType.fields | The fields the dataset returns, each with its name and the name of its type. |
type.name of a field | The type of the field’s value, such as CustomDateTime for ts, String, or Int. |
isDeprecated and deprecationReason | Whether a dataset is deprecated and, when it is, the dataset to use instead. |