This repository provides a minimal example of how to use the new subgraph composition feature of The Graph.
The Graph is a powerful, decentralized protocol that enables seamless querying and indexing of blockchain data. It simplifies the complex process of querying blockchain data, making DApp development faster and easier.
Subgraph composition allows a subgraph to depend on another subgraph as a data source, allowing one subgraph to consume and react to the data or entity changes of another subgraph. This feature enables modular subgraph architectures.
Instead of interacting directly with on-chain data, a subgraph can be set up to listen to updates from another subgraph and react to entity changes. This can be used for a variety of use cases, such as aggregating data from multiple subgraphs or triggering actions based on changes in external subgraph entities.
The example defines 3 source subgraphs:
- block-time-subgraph - a subgraph that calculates the block time for each block
- block-cost-subgraph - a subgraph that indexes the cost of each block
- block-size-subgraph - a subgraph that indexes the size of each block
and a composed subgraph that combines and aggregates the information from the 3 source subgraphs:
- block-stats-subgraph - a subgraph that collects statistics about blocks