The Graph: A Decentralized Query Protocol for Blockchains

Authors Tal, Yaniv; Thibodeau, Brandon; Hernandez, Jannis; et al. (Edge & Node / The Graph Foundation)
Year 2020
Project The Graph
License MIT
Official Source https://thegraph.com/docs/en/

This page is an educational summary and analysis of an official whitepaper or technical paper, written for reference purposes. It is not a verbatim reproduction. CryptoGloss does not claim authorship of the original work. All intellectual property rights remain with the original author(s). The official document is linked above.

The Graph is a decentralized indexing and querying protocol for blockchains, described in the 2020 protocol specification by Yaniv Tal (CEO), Brandon Thibodeau (CTO), and Jannis Hernandez of Edge & Node (the founding team). The Graph solves the blockchain data access problem: raw blockchain data (events, transactions, state) is not structured for efficient querying, making it difficult for dApps to answer questions like “show me all trades by address X on Uniswap v2 in the past 30 days” without either running specialized off-chain infrastructure or trusting a centralized API.

The Graph enables developers to define subgraphs (open-source data transformation schemas) that index blockchain events into a GraphQL API, served by a decentralized network of Indexers who are economically incentivized to provide accurate, available query responses.

> Documentation and Protocol Specification: Available at thegraph.com/docs.


Publication and Context

Before The Graph (circa 2018), dApps faced a stark choice for blockchain data access:

  1. Run your own Ethereum archive node + custom indexer — expensive (~$5,000+/month for an Ethereum archive node), operationally complex, and not open to others
  2. Use a centralized API provider (Infura, Alchemy, The Graph’s own hosted service) — fast and cheap but requires trusting a centralized provider that can censor, fail, or change pricing

The Graph’s hosted service (2020) proved the concept. The protocol decentralization (mainnet 2021) moved the hosted service’s functionality to a permissionless network.


Subgraphs

A subgraph is an open-source data indexing specification consisting of:

1. Subgraph Manifest (subgraph.yaml):

  • Which contracts to index (addresses + ABIs)
  • Which events/functions to track
  • Starting block number

2. GraphQL Schema (schema.graphql):

  • Entity types and relationships defining how indexed data is structured

3. Mapping functions (AssemblyScript):

  • Transform raw blockchain events into entities of the defined schema

When an Indexer syncs a subgraph, their node replays all historical events from the specified contracts and runs the mapping functions to build the entity database. This database is then exposed as a GraphQL API endpoint.


Network Participants

Role Function Token Mechanics
Indexers Run subgraph nodes; serve queries; earn query fees + indexing rewards Stake GRT; slashed for serving incorrect data
Curators Signal on high-quality subgraphs (share of query fees go to curators) Bond GRT into subgraph bonding curves
Delegators Stake GRT to specific Indexers without running nodes Earn portion of Indexer rewards
Consumers Query subgraphs; pay query fees in GRT Pay per-query fees
Developers Publish subgraphs; define data schemas No GRT requirement to publish

Curation Signal and Discovery

Curators signal quality by bonding GRT into subgraph bonding curves:

  • The more GRT bonded to a subgraph, the higher its “signal”
  • High-signal subgraphs attract more Indexers (more indexing rewards)
  • Curators receive a share of the query fees for the subgraphs they signal
  • Curators who signal early on valuable subgraphs earn more (like a bonding curve for discovery)

This creates a decentralized curation market for determining which subgraphs are important enough to be redundantly indexed.


Indexer Economics

Indexers earn:

  1. Indexing rewards: GRT token inflation distributed to Indexers proportional to their signal allocation
  2. Query fees: GRT paid per query by consumers, minus a protocol cut

Indexers are slashed for disputes — if a Fisherman (third-party verifier) submits proof that an Indexer returned incorrect data for a query, the Indexer loses GRT stake.

Allocation: Indexers allocate their stake across multiple subgraphs. The ratio of stake to signal determines indexing reward share. Optimizing across subgraphs is an active optimization problem for professional Indexers.


Reality Check

The Graph’s hosted service proved the model: hundreds of millions of queries per day for protocols like Uniswap, Aave, and Balancer depend on The Graph. The subgraph model is genuinely elegant for defining blockchain data schemas.

Caveats:

  • Decentralization is partial: Most production dApps still query The Graph’s hosted service (which itself uses centralized infrastructure) rather than the decentralized network. Migration to the decentralized network has been slower than anticipated.
  • GRT token value: The Indexer economic model requires the GRT token to have sufficient value to create meaningful slashing deterrence and reward incentives. Market conditions affect this.
  • Subgraph limitations: Subgraphs are append-friendly but aggregation queries (e.g., “sum of all fees in the past year”) can be slow or require off-subgraph computation.
  • Competition: Centralized alternatives (Alchemy Subgraphs, GoldRush/Covalent, Envio) often provide better performance for specific use cases.

Legacy

The Graph pioneered open, decentralized API infrastructure for blockchain data, with the subgraph model widely adopted across the industry (Uniswap, Aave, Compound, Balancer all publish official subgraphs). The GraphQL schema approach for blockchain data has become a standard design pattern. The curator/signal mechanism is an interesting application of token-curated registries for discovering quality.


Related Terms


Research

  • Tal, Y., Thibodeau, B., Hernandez, J., et al. (2020). The Graph Network In Depth. The Graph Foundation.

— Primary protocol specification. Covers subgraph lifecycle, Indexer economics, Curator bonding curves, and slashing conditions.

  • Zargham, M., et al. (2021). The Graph Token Economics. BlockScience.

— Formal token economic model for GRT; covers equilibrium analysis of Indexer allocation strategies and Curator incentive compatibility.

  • Benet, J. (2014). IPFS — Content Addressed, Versioned, P2P File System. Protocol Labs.

— The Graph uses IPFS to distribute subgraph manifests (the Subgraph ID is the IPFS hash of the manifest), making subgraph definitions content-addressed.