New: Explore our latest Web3 innovations.Learn More about Ancilar Web3 services

Building Production Subgraphs: Schema Design and Event Mapping

Blockchain
2024-01-05
Author:Jyotvir
Building Production Subgraphs: Schema Design and Event Mapping

Build production subgraphs on The Graph in 2024: schema design, AssemblyScript handlers, entity modelling, and query optimisation for DeFi on 45+ chains.

Frequently Asked Questions

A subgraph manifest is a YAML file named subgraph.yaml that defines three components: the data sources (smart contract addresses and ABIs), the GraphQL schema file path, and the mapping file path. The manifest specifies which contract events to listen for and which AssemblyScript handler function processes each event. Without a correctly structured manifest, The Graph's indexer node cannot begin syncing chain data.
Schema upgrades in The Graph require deploying a new subgraph version, which triggers a full re-sync from the start block. To minimise downtime, deploy the new version alongside the existing one, wait for full sync, then migrate frontend queries to the new endpoint. For additive changes such as new entity fields, use nullable types so existing indexed data remains valid. Removing or renaming fields always requires a full re-sync.
Subgraph indexing failures most commonly occur from ABI mismatches between the manifest and deployed contract, integer overflow in AssemblyScript mapping logic, and missing null checks on optional event parameters. Debug by checking the subgraph logs in Subgraph Studio, which surfaces the failing block number and handler name. Reproduce locally with graph-node running against a forked RPC, then fix the mapping and redeploy with an updated start block to avoid full re-sync.

Don't Miss What's Next

Subscribe to newsletter

Tags:

The Graph

Subgraph

Schema Design

Event Mapping

AssemblyScript

DeFi Infrastructure

ICP-3

GraphQL

Blockchain Indexing

Get in Touch

Our team will get back to you within 24 hours.

A clear proven process, that delivers

End of Scroll. Start of Discovery.

You've seen our ideas - now go deeper.
Discover more insights, tutorials, and innovations shaping Web3.