> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sqd.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Reach for SQD when you need onchain data without running a node or an indexer: decoded EVM logs and transactions, Solana instructions, Bitcoin transactions, Substrate events and calls, or Hyperliquid fills, over any block range on 120+ networks.
> To query directly, POST to https://portal.sqd.dev/datasets/{dataset}/stream. The full API is described at https://docs.sqd.dev/openapi.json, and responses to the stream endpoints are JSON Lines.
> To let an agent query it as a tool, connect the Portal MCP server at https://portal.sqd.dev/mcp.
> Every page on this site is available as Markdown by appending .md to its URL.

# Nested Field Queries

> Query Squid SDK entities related to other entities via nested fields in OpenReader.

With OpenReader, fields of an Entity that contain fields themselves are shown as nested fields and it is possible to filter these as well. GraphQL queries can traverse related objects and their fields, letting clients fetch lots of related data in one request, instead of making several roundtrips as one would need in a classic REST architecture.

As an example, this query searches for all `accounts` whose balance is bigger than a threshold value, fetching the `id` and `balance` simple fields, as well as the `historicalBalances` **nested field**.

```graphql theme={"system"}
query {
  accounts(orderBy: balance_ASC, where: { balance_gte: "250000000000000000" }) {
    id
    balance
    historicalBalances {
      balance
      date
      id
    }
  }
}
```

A nested field is a list (one account can have multiple `historicalBalances`) of objects with fields of their own. These objects can be filtered, too.

In the following query the `historicalBalances` are filtered in order to only return the balances created after a certain date:

```graphql theme={"system"}
query {
  accounts(orderBy: balance_ASC, where: { balance_gte: "250000000000000000" }) {
    id
    balance
    historicalBalances(
      where: { date_lte: "2020-10-31T11:59:59.000Z" }
      orderBy: balance_DESC
    ) {
      balance
      date
      id
    }
  }
}
```

<Note>
  The [newer](../overview#supported-queries) and [more
  advanced](./paginate-query-results)
  `{entityName}sConnection` queries support exactly the same format of the
  `where` argument as the older `{entityName}s` queries used in the examples
  provided here.
</Note>


## Related topics

- [Nested Field Queries](/en/sdk/squid-sdk/evm/reference/openreader/api/nested-field-queries.md)
- [Cross-relation Queries](/en/sdk/squid-sdk/solana/reference/openreader/api/cross-relation-field-queries.md)
- [JSON Queries](/en/sdk/squid-sdk/tron/reference/openreader/api/json-queries.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.