What is Subgraph?

1 min read Updated

A subgraph is a data indexing definition for The Graph protocol that specifies what blockchain data to extract, how to transform it, and how to store it — creating a queryable API from raw on-chain events.

WHY IT MATTERS

Subgraphs are the recipes for indexed blockchain data. A developer defines: which smart contracts to watch, which events to index, how to transform event data into stored entities, and the GraphQL schema for querying.

Once deployed, The Graph's indexer nodes process the subgraph — scanning the blockchain for matching events, executing the transformation logic, and serving query results through a GraphQL API.

Subgraphs power the data layer of major dApps. Uniswap's analytics, Aave's dashboards, and hundreds of other applications rely on subgraphs for fast, structured access to on-chain data.

FREQUENTLY ASKED QUESTIONS

How do I create a subgraph?
Define a schema (entities), write event handlers (AssemblyScript), and configure a manifest (which contracts/events). Deploy to The Graph's hosted service or decentralized network. Graph CLI handles scaffolding.
Are subgraphs real-time?
Near real-time. Indexers process blocks as they're produced, with a typical delay of seconds to minutes. Not suitable for sub-second requirements — use direct RPC for that.
What language are subgraph handlers written in?
AssemblyScript — a TypeScript-like language that compiles to WebAssembly. It handles the mapping logic that transforms blockchain events into stored entities.

FURTHER READING

Enforce policies on every tool call

Intercept is the open-source MCP proxy that enforces YAML policies on AI agent tool calls. No code changes needed.

npx -y @policylayer/intercept
github.com/policylayer/intercept →
// GET IN TOUCH

Have a question or want to learn more? Send us a message.

Message sent.

We'll get back to you soon.