The Graph and Subgraphs for Data Indexing

The Graph indexes blockchain data into subgraphs queryable via GraphQL, so dApps skip manual block scanning.

TECH & NETWORKS5 min readBy AlgoSys Editorial TeamPublished Apr 25, 2026Updated Jun 26, 2026
Contents

The Graph is a decentralized protocol for indexing and querying blockchain data. It helps developers quickly retrieve and process data from networks such as Ethereum and Arbitrum, without having to wrestle with heavy infrastructure. Before it existed, you either had to rely on centralized services or spin up your own nodes and indexers, which was both expensive and fragile: a single failure in such a service would cut off data access for the entire application.

The problem the protocol solves can be stated simply: give smart contracts and decentralized applications (dApps, programs that run directly on the blockchain without an intermediary) easy access to on-chain data. The Graph lets you describe open APIs called subgraphs and query them using the GraphQL query language. Work on the protocol began in 2018, and the mainnet launched in July 2021.

In the Web3 stack, The Graph occupies the data layer: it sits between the blockchain and an application's frontend. This makes data retrieval faster and more reliable than going directly to nodes (network peers) or to centralized indexers.

MECHANICS

The network runs on three roles: indexers, curators, and users. Indexers operate nodes that process blockchain data and store it in a database ready to answer queries. For this service they earn GRT tokens, with income coming from query fees and network rewards, so maintaining the infrastructure is in their economic interest.

For the protocol to know what exactly to index, a developer describes a subgraph. This is done through a manifest (the subgraph.yaml file), which lists the required smart contracts, event handlers, and data transformation rules. The rules themselves, the mappings, are written in AssemblyScript and turn raw blockchain events into a neatly structured format. The indexer then processes the events and serves the result through a GraphQL API.

The economics close around GRT staking. When a subgraph is deployed, indexers stake GRT to signal their readiness to index it. Curators, in turn, stake GRT on the subgraphs they consider valuable, and earn a portion of query fees in return. Users pay for each data query, and that payment is distributed among indexers and curators. The result is a closed loop of incentives where every participant benefits from supporting the network.

KEY COMPONENTS

The Graph Network is a decentralized protocol assembled from several roles and technical elements that together provide access to blockchain data through a distributed infrastructure. Its main parts:

  • Indexers: node operators who maintain the network's infrastructure, process blockchain data, and serve queries; their income comes from query fees and network rewards.
  • Curators: participants who stake GRT to signal a subgraph's value, and earn a share of query fees in return.
  • Delegators: GRT holders who delegate their tokens to indexers, strengthening network security and earning rewards themselves.
  • Developers: those who describe subgraphs through a manifest and mappings to index the data they need.
  • Subgraphs: open APIs that index data from specific smart contracts and serve it on request via GraphQL.
  • GRT (Graph Token): the network's working token, required for staking, delegating, and paying for queries.
  • Graph Node: the software that indexers run to process and store blockchain data.
  • Graph Client: libraries through which developers interact with subgraphs and query data.

APPLICATIONS

The Graph powers many decentralized applications across different blockchains. DeFi protocols, NFT marketplaces, and DAOs rely on its indexing to access data in real time. A clear example is Uniswap, the leading decentralized exchange: it uses The Graph to display trading history and the state of current liquidity pools.

DeFi (decentralized finance) depends on the protocol especially heavily. Applications constantly need token prices, liquidity levels, and transaction histories, and subgraphs deliver all of this in a convenient form. For instance, Aave and Compound use subgraphs to display user positions and protocol statistics, which makes the interface clearer and helps users make more informed decisions in these complex ecosystems.

NFT platforms benefit just as much. With The Graph they track asset ownership, sales history, and metadata, allowing NFTs to be displayed and searched quickly on marketplaces. The protocol's ability to handle large volumes of events is what makes it indispensable for scalable Web3 applications.

To make this concrete, imagine an NFT marketplace that wants to show the page for a single collection: current owners, the last ten sales, and the floor price. Without indexing, the frontend would have to scan all the blocks where Transfer events for that contract appeared, stitch them together by token, and recalculate prices, and on a popular collection that means thousands of blocks and a noticeable delay. With a subgraph, the Transfer and Sale events are already organized into owner and sales tables, so a single GraphQL query returns the ready-built page almost instantly. All the heavy lifting was done in advance by the indexer; the application simply reads the result.

TRADE-OFFS

Compared to querying blockchain nodes directly, The Graph makes a developer's life considerably easier and speeds up data access. But there is a price to pay for the convenient abstraction. Relying on indexers adds a layer of trust in them, although the decentralized nature of the network reduces the risk of a single point of failure.

If you compare it to centralized indexers, each approach has its strengths.

Criterion The Graph Centralized indexer
Censorship resistance high low
Decentralization yes no
Latency on narrow queries higher often lower
Transparency high limited
Query cost fee in GRT often free

A centralized service can answer individual queries with lower latency, but it lacks the security and transparency of a distributed network. Cost is also worth considering: The Graph charges a fee for queries, while many centralized alternatives are free.

Finally, the protocol's throughput is bounded by the number of indexers and their capacity. The network is designed to scale, but during extreme query loads or with a shortage of active indexers, latency and cost can rise. The economic incentives are specifically designed to keep indexing capacity sufficient, and the team continuously refines this aspect.

FAQ

How does The Graph differ from a standard RPC call to a node?

A direct call to a node (a blockchain peer) returns raw data block by block, and to collect, say, the full trading history of a specific pool, an application would have to scan through thousands of blocks manually. The Graph does this heavy lifting upfront: an indexer walks the chain once, organizes events into a convenient structure, and stores them in a database. The application simply asks for the ready-made answer via GraphQL and gets it quickly, with no block scanning on its own side.

What is a subgraph in plain terms?

A subgraph is an open API that describes which smart contracts to listen to, which of their events to capture, and in what format to store the data. A developer sets these rules in a manifest file and in AssemblyScript mappings, after which The Graph network starts indexing the relevant events and serving them on request. Essentially, a subgraph turns a contract's event stream into a table that is convenient to query.

What is the GRT token used for?

GRT is the network's working token, and it ties all participants together economically. Users pay GRT for each data query, indexers stake GRT to earn the right to index a subgraph and earn from queries, curators stake GRT on subgraphs they consider valuable, and delegators pass their GRT to indexers and share in their rewards. In this way, query payments become an incentive to maintain the infrastructure.

Can you trust data from The Graph?

The data comes not from a single company but from a network of independent indexers who stake their own GRT, so malicious or poor-quality indexing hurts their own funds. This reduces the risk of a single point of failure and censorship compared to a centralized service. Trust does not disappear entirely, since you are relying on indexers to have processed the chain honestly, but decentralization and economic penalties make data manipulation unprofitable.

When would a centralized indexer be better than The Graph?

If an application needs minimal latency on a specific narrow set of queries and is willing to accept dependence on a single provider, a centralized solution can respond faster and often at no cost. The Graph wins where censorship resistance, transparency, and the absence of a single point of failure matter, but queries come with a fee. The choice comes down to what matters more in a given project: speed and cost versus decentralization and reliability.

Put this to work in the terminal

Live charts, derivatives, on-chain and macro data, free.

Open terminal →