Staking Data
Queries

Nested Object Queries

Learn how to traverse relationships between objects using hierarchical queries.

Nested Object Queries

This represents an example of hierarchical querying where multiple objects can be accessed in a structured manner.

The maximum depth is 2.

Example Query

Fetch the Allnodes provider with its associated reward options and validators:

{
  providers(where: { names: ["Allnodes"] }, limit: 1) {
    id
    name
    slug
    rewardOptions(where: { typeKeys: ["pos"] }, limit: 10) {
      id
      inputAssets(limit: 10) {
        name
      }
      validators(limit: 10) {
        id
        address
      }
    }
  }
}

How It Works

  1. The query starts at the providers level, filtering for "Allnodes"
  2. Within each provider, it retrieves rewardOptions filtered by type
  3. For each reward option, it fetches inputAssets and validators

This nested structure allows you to get related data in a single request instead of making multiple API calls.

Always specify limit at each level of nesting to control the amount of data returned and optimize performance.

On this page