How to query metadata with GraphQL API

Metadata are relevant information regarding the scope of data in the GraphQL API. They can help you understand the relationship and the utility of the request processes.

To check GraphQL API’s metadata, follow the steps described on How to query GraphQL requests on Postman using the https://api.azionapi.net/metrics/graphql URL.

Then, on Postman’s GraphQL request code box, add the following Introspection Query:

query introspectionQuery {
__type(name: "Query") {
name
description
fields {
name
description
type {
ofType {
fields {
name
type {
name
}
}
}
}
}
}
}

Send your request. You’ll receive a response similar to this:

{
"data": {
"__type": {
"name": "Query",
"description": "Class responsible for gathering the queries from the datasets and returning them in the form of graphql schema to the Django view.",
"fields": [
{
{
"name": "dataStreamedMetrics",
"description": "Data Streamed Metrics dataset query by Minute, Hour and Day with aggregate options.",
"type": {
"ofType": {
"fields": [
{
"name": "ts",
"type": {
"name": "CustomDateTime"
}
},
{
"name": "configurationId",
"type": {
"name": "String"
}
},
{
"name": "endpointType",
"type": {
"name": "String"
}
},
{
"name": "httpMetrics",
"description": "Http Metrics dataset query by Minute, Hour and Day with aggregate options.",
"type": {
"ofType": {
"fields": [
{
"name": "ts",
"type": {
"name": "CustomDateTime"
}
},
{
"name": "configurationId",
"type": {
"name": "String"
}
},
{
"name": "host",
"type": {
"name": "String"
}
},
{
"name": "requestMethod",
"type": {
"name": "String"
}
}
]
}
}
}
]
}
}
}

The API returns the following metadata:

  • Datasets available to query, such as dataStreamedMetrics and httpMetrics.
  • Available fields for each dataset query.
  • Each type for returnable fields, such as Int, String, DateTime, and so on.

For more information on the available datasets with the GraphQL API, visit the datasets documentation page.

Watch a video tutorial on consulting metadata with GraphQL on Azion’s YouTube channel:


Contributors