Staking Data
Queries

Simple Object Queries

Learn how to fetch single data entries using simple GraphQL queries.

Simple Object Queries

You can fetch a single data entry using a simple object query. Any argument has to be an array (except booleans).

Example Query

{
  assets(where: { symbols: ["ETH"] }, limit: 1) {
    id
    name
    slug
    description
    symbol
  }
}
{
  "data": {
    "assets": [
      {
        "id": "asset-id",
        "name": "Ethereum",
        "slug": "ethereum-2-0",
        "description": "the worlds largest and most decentralised Layer1 blockchain...",
        "symbol": "ETH"
      }
    ]
  }
}

Response Structure

The response contains a top-level data field with nested results. The assets field contains an array of asset objects with the requested fields like id, name, slug, description, and symbol.

Accessing Response Data

Using forEach loop:

data.assets.forEach(asset => {
  console.log(asset.name, asset.symbol);
});

Using array destructuring:

const [ethereum] = data.assets;
console.log(ethereum.name); // "Ethereum"

Remember that limit is required for all queries, even when you expect only one result.

On this page