https://github.com/graphprotocol/example-composable-subgraph
An example composable subgraph
https://github.com/graphprotocol/example-composable-subgraph
Last synced: 3 months ago
JSON representation
An example composable subgraph
- Host: GitHub
- URL: https://github.com/graphprotocol/example-composable-subgraph
- Owner: graphprotocol
- Created: 2025-04-01T11:33:36.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-04-01T12:15:40.000Z (10 months ago)
- Last Synced: 2025-04-01T13:26:15.259Z (10 months ago)
- Language: TypeScript
- Size: 51.8 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Subgraph Composition Example
This repository provides a minimal example of how to use the new subgraph composition feature of [The Graph][0].
## What is The Graph?
[The Graph][0] 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.
## What is subgraph composition?
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.
## How to use subgraph composition?
The example defines 3 source subgraphs:
- [block-time-subgraph](./block-time-subgraph) - a subgraph that calculates the block time for each block
- [block-cost-subgraph](./block-cost-subgraph) - a subgraph that indexes the cost of each block
- [block-size-subgraph](./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](./block-stats-subgraph) - a subgraph that collects statistics about blocks
[0]: https://thegraph.com/