Skip to content

Commit

Permalink
Run pnpm build
Browse files Browse the repository at this point in the history
  • Loading branch information
benface committed Mar 6, 2025
1 parent 679f4bb commit 8db2b50
Show file tree
Hide file tree
Showing 44 changed files with 5,022 additions and 1 deletion.
44 changes: 44 additions & 0 deletions website/route-lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
/ar/subgraphs/cookbook/near/
/ar/subgraphs/cookbook/polymarket/
/ar/subgraphs/cookbook/secure-api-keys-nextjs/
/ar/subgraphs/cookbook/subgraph-composition-three-sources/
/ar/subgraphs/cookbook/subgraph-composition/
/ar/subgraphs/cookbook/subgraph-debug-forking/
/ar/subgraphs/cookbook/subgraph-uncrashable/
/ar/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -126,6 +128,8 @@
/cs/subgraphs/cookbook/near/
/cs/subgraphs/cookbook/polymarket/
/cs/subgraphs/cookbook/secure-api-keys-nextjs/
/cs/subgraphs/cookbook/subgraph-composition-three-sources/
/cs/subgraphs/cookbook/subgraph-composition/
/cs/subgraphs/cookbook/subgraph-debug-forking/
/cs/subgraphs/cookbook/subgraph-uncrashable/
/cs/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -209,6 +213,8 @@
/de/subgraphs/cookbook/near/
/de/subgraphs/cookbook/polymarket/
/de/subgraphs/cookbook/secure-api-keys-nextjs/
/de/subgraphs/cookbook/subgraph-composition-three-sources/
/de/subgraphs/cookbook/subgraph-composition/
/de/subgraphs/cookbook/subgraph-debug-forking/
/de/subgraphs/cookbook/subgraph-uncrashable/
/de/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -294,6 +300,8 @@
/en/subgraphs/cookbook/near/
/en/subgraphs/cookbook/polymarket/
/en/subgraphs/cookbook/secure-api-keys-nextjs/
/en/subgraphs/cookbook/subgraph-composition-three-sources/
/en/subgraphs/cookbook/subgraph-composition/
/en/subgraphs/cookbook/subgraph-debug-forking/
/en/subgraphs/cookbook/subgraph-uncrashable/
/en/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -379,6 +387,8 @@
/es/subgraphs/cookbook/near/
/es/subgraphs/cookbook/polymarket/
/es/subgraphs/cookbook/secure-api-keys-nextjs/
/es/subgraphs/cookbook/subgraph-composition-three-sources/
/es/subgraphs/cookbook/subgraph-composition/
/es/subgraphs/cookbook/subgraph-debug-forking/
/es/subgraphs/cookbook/subgraph-uncrashable/
/es/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -464,6 +474,8 @@
/fr/subgraphs/cookbook/near/
/fr/subgraphs/cookbook/polymarket/
/fr/subgraphs/cookbook/secure-api-keys-nextjs/
/fr/subgraphs/cookbook/subgraph-composition-three-sources/
/fr/subgraphs/cookbook/subgraph-composition/
/fr/subgraphs/cookbook/subgraph-debug-forking/
/fr/subgraphs/cookbook/subgraph-uncrashable/
/fr/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -549,6 +561,8 @@
/hi/subgraphs/cookbook/near/
/hi/subgraphs/cookbook/polymarket/
/hi/subgraphs/cookbook/secure-api-keys-nextjs/
/hi/subgraphs/cookbook/subgraph-composition-three-sources/
/hi/subgraphs/cookbook/subgraph-composition/
/hi/subgraphs/cookbook/subgraph-debug-forking/
/hi/subgraphs/cookbook/subgraph-uncrashable/
/hi/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -634,6 +648,8 @@
/it/subgraphs/cookbook/near/
/it/subgraphs/cookbook/polymarket/
/it/subgraphs/cookbook/secure-api-keys-nextjs/
/it/subgraphs/cookbook/subgraph-composition-three-sources/
/it/subgraphs/cookbook/subgraph-composition/
/it/subgraphs/cookbook/subgraph-debug-forking/
/it/subgraphs/cookbook/subgraph-uncrashable/
/it/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -719,6 +735,8 @@
/ja/subgraphs/cookbook/near/
/ja/subgraphs/cookbook/polymarket/
/ja/subgraphs/cookbook/secure-api-keys-nextjs/
/ja/subgraphs/cookbook/subgraph-composition-three-sources/
/ja/subgraphs/cookbook/subgraph-composition/
/ja/subgraphs/cookbook/subgraph-debug-forking/
/ja/subgraphs/cookbook/subgraph-uncrashable/
/ja/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -802,6 +820,8 @@
/ko/subgraphs/cookbook/near/
/ko/subgraphs/cookbook/polymarket/
/ko/subgraphs/cookbook/secure-api-keys-nextjs/
/ko/subgraphs/cookbook/subgraph-composition-three-sources/
/ko/subgraphs/cookbook/subgraph-composition/
/ko/subgraphs/cookbook/subgraph-debug-forking/
/ko/subgraphs/cookbook/subgraph-uncrashable/
/ko/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -887,6 +907,8 @@
/mr/subgraphs/cookbook/near/
/mr/subgraphs/cookbook/polymarket/
/mr/subgraphs/cookbook/secure-api-keys-nextjs/
/mr/subgraphs/cookbook/subgraph-composition-three-sources/
/mr/subgraphs/cookbook/subgraph-composition/
/mr/subgraphs/cookbook/subgraph-debug-forking/
/mr/subgraphs/cookbook/subgraph-uncrashable/
/mr/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -970,6 +992,8 @@
/nl/subgraphs/cookbook/near/
/nl/subgraphs/cookbook/polymarket/
/nl/subgraphs/cookbook/secure-api-keys-nextjs/
/nl/subgraphs/cookbook/subgraph-composition-three-sources/
/nl/subgraphs/cookbook/subgraph-composition/
/nl/subgraphs/cookbook/subgraph-debug-forking/
/nl/subgraphs/cookbook/subgraph-uncrashable/
/nl/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -1053,6 +1077,8 @@
/pl/subgraphs/cookbook/near/
/pl/subgraphs/cookbook/polymarket/
/pl/subgraphs/cookbook/secure-api-keys-nextjs/
/pl/subgraphs/cookbook/subgraph-composition-three-sources/
/pl/subgraphs/cookbook/subgraph-composition/
/pl/subgraphs/cookbook/subgraph-debug-forking/
/pl/subgraphs/cookbook/subgraph-uncrashable/
/pl/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -1138,6 +1164,8 @@
/pt/subgraphs/cookbook/near/
/pt/subgraphs/cookbook/polymarket/
/pt/subgraphs/cookbook/secure-api-keys-nextjs/
/pt/subgraphs/cookbook/subgraph-composition-three-sources/
/pt/subgraphs/cookbook/subgraph-composition/
/pt/subgraphs/cookbook/subgraph-debug-forking/
/pt/subgraphs/cookbook/subgraph-uncrashable/
/pt/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -1221,6 +1249,8 @@
/ro/subgraphs/cookbook/near/
/ro/subgraphs/cookbook/polymarket/
/ro/subgraphs/cookbook/secure-api-keys-nextjs/
/ro/subgraphs/cookbook/subgraph-composition-three-sources/
/ro/subgraphs/cookbook/subgraph-composition/
/ro/subgraphs/cookbook/subgraph-debug-forking/
/ro/subgraphs/cookbook/subgraph-uncrashable/
/ro/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -1306,6 +1336,8 @@
/ru/subgraphs/cookbook/near/
/ru/subgraphs/cookbook/polymarket/
/ru/subgraphs/cookbook/secure-api-keys-nextjs/
/ru/subgraphs/cookbook/subgraph-composition-three-sources/
/ru/subgraphs/cookbook/subgraph-composition/
/ru/subgraphs/cookbook/subgraph-debug-forking/
/ru/subgraphs/cookbook/subgraph-uncrashable/
/ru/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -1391,6 +1423,8 @@
/sv/subgraphs/cookbook/near/
/sv/subgraphs/cookbook/polymarket/
/sv/subgraphs/cookbook/secure-api-keys-nextjs/
/sv/subgraphs/cookbook/subgraph-composition-three-sources/
/sv/subgraphs/cookbook/subgraph-composition/
/sv/subgraphs/cookbook/subgraph-debug-forking/
/sv/subgraphs/cookbook/subgraph-uncrashable/
/sv/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -1476,6 +1510,8 @@
/tr/subgraphs/cookbook/near/
/tr/subgraphs/cookbook/polymarket/
/tr/subgraphs/cookbook/secure-api-keys-nextjs/
/tr/subgraphs/cookbook/subgraph-composition-three-sources/
/tr/subgraphs/cookbook/subgraph-composition/
/tr/subgraphs/cookbook/subgraph-debug-forking/
/tr/subgraphs/cookbook/subgraph-uncrashable/
/tr/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -1559,6 +1595,8 @@
/uk/subgraphs/cookbook/near/
/uk/subgraphs/cookbook/polymarket/
/uk/subgraphs/cookbook/secure-api-keys-nextjs/
/uk/subgraphs/cookbook/subgraph-composition-three-sources/
/uk/subgraphs/cookbook/subgraph-composition/
/uk/subgraphs/cookbook/subgraph-debug-forking/
/uk/subgraphs/cookbook/subgraph-uncrashable/
/uk/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -1644,6 +1682,8 @@
/ur/subgraphs/cookbook/near/
/ur/subgraphs/cookbook/polymarket/
/ur/subgraphs/cookbook/secure-api-keys-nextjs/
/ur/subgraphs/cookbook/subgraph-composition-three-sources/
/ur/subgraphs/cookbook/subgraph-composition/
/ur/subgraphs/cookbook/subgraph-debug-forking/
/ur/subgraphs/cookbook/subgraph-uncrashable/
/ur/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -1727,6 +1767,8 @@
/vi/subgraphs/cookbook/near/
/vi/subgraphs/cookbook/polymarket/
/vi/subgraphs/cookbook/secure-api-keys-nextjs/
/vi/subgraphs/cookbook/subgraph-composition-three-sources/
/vi/subgraphs/cookbook/subgraph-composition/
/vi/subgraphs/cookbook/subgraph-debug-forking/
/vi/subgraphs/cookbook/subgraph-uncrashable/
/vi/subgraphs/cookbook/transfer-to-the-graph/
Expand Down Expand Up @@ -1812,6 +1854,8 @@
/zh/subgraphs/cookbook/near/
/zh/subgraphs/cookbook/polymarket/
/zh/subgraphs/cookbook/secure-api-keys-nextjs/
/zh/subgraphs/cookbook/subgraph-composition-three-sources/
/zh/subgraphs/cookbook/subgraph-composition/
/zh/subgraphs/cookbook/subgraph-debug-forking/
/zh/subgraphs/cookbook/subgraph-uncrashable/
/zh/subgraphs/cookbook/transfer-to-the-graph/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
title: Aggregate Data Using Subgraph Composition
sidebarTitle: 'Build a Composable Subgraph with Multiple Subgraphs'
---

Optimize your Subgraph by merging data from three independent, source Subgraphs into a single composable Subgraph to enhance data aggregation.

> Important Reminders:
>
> - Subgraph composition is built into the CLI, and you can deploy with [Subgraph Studio](https://thegraph.com/studio/).
> - This feature requires `specVersion` 1.3.0.
## Overview

Subgraph composition empowers you to use one Subgraph as a data source for another, allowing it to consume and respond to entity changes. Instead of fetching onchain data directly, a Subgraph can listen for updates from another Subgraph and react to changes. This is useful for aggregating data from multiple Subgraphs or triggering actions based on external updates.

## Prerequisites

To deploy **all** Subgraphs locally, you must have the following:

- A [Graph Node](https://github.com/graphprotocol/graph-node) instance running locally
- An [IPFS](https://docs.ipfs.tech/) instance running locally
- [Node.js](https://nodejs.org) and npm

## Get Started

The following guide provides examples for defining three source Subgraphs to create one powerful composed Subgraph.

### Specifics

- To keep this example simple, all source Subgraphs use only block handlers. However, in a real environment, each source Subgraph will use data from different smart contracts.
- The examples below show how to import and extend the schema of another Subgraph to enhance its functionality.
- Each source Subgraph is optimized with a specific entity.
- All the commands listed install the necessary dependencies, generate code based on the GraphQL schema, build the Subgraph, and deploy it to your local Graph Node instance.

### Step 1. Deploy Block Time Source Subgraph

This first source Subgraph calculates the block time for each block.

- It imports schemas from other Subgraphs and adds a `block` entity with a `timestamp` field, representing the time each block was mined.
- It listens to time-related blockchain events (e.g., block timestamps) and processes this data to update the Subgraph's entities accordingly.

To deploy this Subgraph locally, run the following commands:

```bash
npm install
npm run codegen
npm run build
npm run create-local
npm run deploy-local
```

### Step 2. Deploy Block Cost Source Subgraph

This second source Subgraph indexes the cost of each block.

#### Key Functions

- It imports schemas from other Subgraphs and adds a `block` entity with cost-related fields.
- It listens to blockchain events related to costs (e.g. gas fees, transaction costs) and processes this data to update the Subgraph's entities accordingly.

To deploy this Subgraph locally, run the same commands as above.

### Step 3. Define Block Size in Source Subgraph

This third source Subgraph indexes the size of each block. To deploy this Subgraph locally, run the same commands as above.

#### Key Functions

- It imports existing schemas from other Subgraphs and adds a `block` entity with a `size` field representing each block's size.
- It listens to blockchain events related to block sizes (e.g., storage or volume) and processes this data to update the Subgraph's entities accordingly.

### Step 4. Combine Into Block Stats Subgraph

This composed Subgraph combines and aggregates the information from the three source Subgraphs above, providing a unified view of block statistics. To deploy this Subgraph locally, run the same commands as above.

> Note:
>
> - Any change to a source Subgraph will likely generate a new deployment ID.
> - Be sure to update the deployment ID in the data source address of the Subgraph manifest to take advantage of the latest changes.
> - All source Subgraphs should be deployed before the composed Subgraph is deployed.
#### Key Functions

- It provides a consolidated data model that encompasses all relevant block metrics.
- It combines data from three source Subgraphs, and provides a comprehensive view of block statistics, enabling more complex queries and analyses.

## Key Takeaways

- This powerful tool will scale your Subgraph development and allow you to combine multiple Subgraphs.
- The setup includes the deployment of three source Subgraphs and one final deployment of the composed Subgraph.
- This feature unlocks scalability, simplifying both development and maintenance efficiency.

## Additional Resources

- Check out all the code for this example in [this GitHub repo](https://github.com/isum/subgraph-composition-example).
- To add advanced features to your Subgraph, check out [Subgraph advanced features](/developing/creating/advanced/).
- To learn more about aggregations, check out [Timeseries and Aggregations](/subgraphs/developing/creating/advanced/#timeseries-and-aggregations).
Loading

0 comments on commit 8db2b50

Please sign in to comment.