# GraphiQL Playground

import DocButton from '~/components/webkit/DocButton.vue';

You can see how to access the GraphiQL Playground on the GraphQL API first steps documentation.

<DocButton href="/en/documentation/devtools/graphql-api/first-steps/#accessing-graphql-playground" label="Access GraphiQL Playground" kind="secondary" size="medium" />

You can use the playground to run queries or to explore how to build them. If you're just starting, you can copy and paste these queries on the playground and discover what each field represents, available operators, and even get real-time validation for erros.

:::tip
After you execute a query, the URL path is updated with an encoded parameter of the specific query you're using. You can copy and share the URL with other users so they can use the same query.
:::

This first query is a type of introspection query, which provides information on fields for datasets:

```graphql
query IntrospectionQuery {
    __schema {
        queryType { name }
        mutationType { name }
        subscriptionType { name }
        types {
            ...FullType       
        }
        directives {
            name
            description
            locations
            args {
                ...InputValue        
            }
        }
    }
}

fragment FullType on __Type {
    kind
    name
    description
    fields(includeDeprecated: true) {
        name
        description
        args {
            ...InputValue
        }
        type {
            ...TypeRef
        }
        isDeprecated
        deprecationReason
    }
    inputFields {
        ...InputValue
    }
    interfaces {
        ...TypeRef
    }
    enumValues(includeDeprecated: true) {
        name
        description
        isDeprecated
        deprecationReason
    }
    possibleTypes {
        ...TypeRef
    }
}

fragment InputValue on __InputValue {
    name
    description
    type { 
        ...TypeRef 
    }
    defaultValue
}

fragment TypeRef on __Type {
    name
    ofType {
        kind
        name
        ofType {
            kind
            name
            ofType {
                kind
                name
                ofType {
                    kind
                    name
                    ofType {
                        kind
                        name
                        ofType {
                            kind
                            name
                            ofType {
                                kind
                                name
                            }
                        }
                    }
                }
            }
        }
    }
}
```

This second query uses the **httpMetrics** dataset, with application data:

```graphql
query HttpCalculatedDataTransferred {
  httpMetrics(
    limit: 2000
    filter: {
      tsRange: {begin:"2023-01-26T10:00:00", end:"2023-01-26T20:00:00"}
    }
    groupBy:[ts]
    orderBy:[ts_ASC]
  )
  {
    ts
    dataTransferredIn
    dataTransferredOut
    dataTransferredTotal
  }
}
```

:::tip
Modify fields and values to explore how GraphQL API and the playground work.
:::

You can also test this query to filter the IPs that generated the most requests identified by the WAF as attacks to explore more possibilities in the playground:

```graphql
query TOP5IPsWAFRequests {
  workloadEvents(
    limit: 5
    filter: {
      tsRange: {
        begin:"2025-01-15T00:00:00"
        end:"2025-01-15T20:00:00"
      },
      wafMatchNe: "-"
      wafAttackFamilyNe: "-"
    }
    aggregate: {
      count: rows
    }
    groupBy:[remoteAddress, wafAttackFamily]
    orderBy:[count_DESC]
  )
  {
    remoteAddress
    wafAttackFamily
    count
  }
}
```

:::tip
For more details, check the [How to identify the Top IPs generating attack traffic using GraphQL API](/en/documentation/products/guides/query-top-ips-attack-traffic-with-graphql/) guide.
:::

Or use this one to filter the top attack types, ranked by occurrence.

```graphql
query Top5Attacks {
  httpMetrics(
    limit: 5
    filter: {
      tsRange: {
        begin:"2025-01-15T00:00:00"
        end:"2025-01-15T20:00:00"
      }
    }
    groupBy:[wafAttackFamily]
    orderBy:[wafRequestsThreat_DESC]
  )
  {
    wafAttackFamily
    wafRequestsThreat
  }
}
```

:::tip
Visit the [Guides page](/en/documentation/products/guides/#graphql-api) and the [GraphQL API documentation](/en/documentation/devtools/graphql-api/) to explore more options for querying data.
:::