Skip to content

Commit 8db2b50

Browse files
committed
Run pnpm build
1 parent 679f4bb commit 8db2b50

File tree

44 files changed

+5022
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+5022
-1
lines changed

website/route-lockfile.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
/ar/subgraphs/cookbook/near/
4242
/ar/subgraphs/cookbook/polymarket/
4343
/ar/subgraphs/cookbook/secure-api-keys-nextjs/
44+
/ar/subgraphs/cookbook/subgraph-composition-three-sources/
45+
/ar/subgraphs/cookbook/subgraph-composition/
4446
/ar/subgraphs/cookbook/subgraph-debug-forking/
4547
/ar/subgraphs/cookbook/subgraph-uncrashable/
4648
/ar/subgraphs/cookbook/transfer-to-the-graph/
@@ -126,6 +128,8 @@
126128
/cs/subgraphs/cookbook/near/
127129
/cs/subgraphs/cookbook/polymarket/
128130
/cs/subgraphs/cookbook/secure-api-keys-nextjs/
131+
/cs/subgraphs/cookbook/subgraph-composition-three-sources/
132+
/cs/subgraphs/cookbook/subgraph-composition/
129133
/cs/subgraphs/cookbook/subgraph-debug-forking/
130134
/cs/subgraphs/cookbook/subgraph-uncrashable/
131135
/cs/subgraphs/cookbook/transfer-to-the-graph/
@@ -209,6 +213,8 @@
209213
/de/subgraphs/cookbook/near/
210214
/de/subgraphs/cookbook/polymarket/
211215
/de/subgraphs/cookbook/secure-api-keys-nextjs/
216+
/de/subgraphs/cookbook/subgraph-composition-three-sources/
217+
/de/subgraphs/cookbook/subgraph-composition/
212218
/de/subgraphs/cookbook/subgraph-debug-forking/
213219
/de/subgraphs/cookbook/subgraph-uncrashable/
214220
/de/subgraphs/cookbook/transfer-to-the-graph/
@@ -294,6 +300,8 @@
294300
/en/subgraphs/cookbook/near/
295301
/en/subgraphs/cookbook/polymarket/
296302
/en/subgraphs/cookbook/secure-api-keys-nextjs/
303+
/en/subgraphs/cookbook/subgraph-composition-three-sources/
304+
/en/subgraphs/cookbook/subgraph-composition/
297305
/en/subgraphs/cookbook/subgraph-debug-forking/
298306
/en/subgraphs/cookbook/subgraph-uncrashable/
299307
/en/subgraphs/cookbook/transfer-to-the-graph/
@@ -379,6 +387,8 @@
379387
/es/subgraphs/cookbook/near/
380388
/es/subgraphs/cookbook/polymarket/
381389
/es/subgraphs/cookbook/secure-api-keys-nextjs/
390+
/es/subgraphs/cookbook/subgraph-composition-three-sources/
391+
/es/subgraphs/cookbook/subgraph-composition/
382392
/es/subgraphs/cookbook/subgraph-debug-forking/
383393
/es/subgraphs/cookbook/subgraph-uncrashable/
384394
/es/subgraphs/cookbook/transfer-to-the-graph/
@@ -464,6 +474,8 @@
464474
/fr/subgraphs/cookbook/near/
465475
/fr/subgraphs/cookbook/polymarket/
466476
/fr/subgraphs/cookbook/secure-api-keys-nextjs/
477+
/fr/subgraphs/cookbook/subgraph-composition-three-sources/
478+
/fr/subgraphs/cookbook/subgraph-composition/
467479
/fr/subgraphs/cookbook/subgraph-debug-forking/
468480
/fr/subgraphs/cookbook/subgraph-uncrashable/
469481
/fr/subgraphs/cookbook/transfer-to-the-graph/
@@ -549,6 +561,8 @@
549561
/hi/subgraphs/cookbook/near/
550562
/hi/subgraphs/cookbook/polymarket/
551563
/hi/subgraphs/cookbook/secure-api-keys-nextjs/
564+
/hi/subgraphs/cookbook/subgraph-composition-three-sources/
565+
/hi/subgraphs/cookbook/subgraph-composition/
552566
/hi/subgraphs/cookbook/subgraph-debug-forking/
553567
/hi/subgraphs/cookbook/subgraph-uncrashable/
554568
/hi/subgraphs/cookbook/transfer-to-the-graph/
@@ -634,6 +648,8 @@
634648
/it/subgraphs/cookbook/near/
635649
/it/subgraphs/cookbook/polymarket/
636650
/it/subgraphs/cookbook/secure-api-keys-nextjs/
651+
/it/subgraphs/cookbook/subgraph-composition-three-sources/
652+
/it/subgraphs/cookbook/subgraph-composition/
637653
/it/subgraphs/cookbook/subgraph-debug-forking/
638654
/it/subgraphs/cookbook/subgraph-uncrashable/
639655
/it/subgraphs/cookbook/transfer-to-the-graph/
@@ -719,6 +735,8 @@
719735
/ja/subgraphs/cookbook/near/
720736
/ja/subgraphs/cookbook/polymarket/
721737
/ja/subgraphs/cookbook/secure-api-keys-nextjs/
738+
/ja/subgraphs/cookbook/subgraph-composition-three-sources/
739+
/ja/subgraphs/cookbook/subgraph-composition/
722740
/ja/subgraphs/cookbook/subgraph-debug-forking/
723741
/ja/subgraphs/cookbook/subgraph-uncrashable/
724742
/ja/subgraphs/cookbook/transfer-to-the-graph/
@@ -802,6 +820,8 @@
802820
/ko/subgraphs/cookbook/near/
803821
/ko/subgraphs/cookbook/polymarket/
804822
/ko/subgraphs/cookbook/secure-api-keys-nextjs/
823+
/ko/subgraphs/cookbook/subgraph-composition-three-sources/
824+
/ko/subgraphs/cookbook/subgraph-composition/
805825
/ko/subgraphs/cookbook/subgraph-debug-forking/
806826
/ko/subgraphs/cookbook/subgraph-uncrashable/
807827
/ko/subgraphs/cookbook/transfer-to-the-graph/
@@ -887,6 +907,8 @@
887907
/mr/subgraphs/cookbook/near/
888908
/mr/subgraphs/cookbook/polymarket/
889909
/mr/subgraphs/cookbook/secure-api-keys-nextjs/
910+
/mr/subgraphs/cookbook/subgraph-composition-three-sources/
911+
/mr/subgraphs/cookbook/subgraph-composition/
890912
/mr/subgraphs/cookbook/subgraph-debug-forking/
891913
/mr/subgraphs/cookbook/subgraph-uncrashable/
892914
/mr/subgraphs/cookbook/transfer-to-the-graph/
@@ -970,6 +992,8 @@
970992
/nl/subgraphs/cookbook/near/
971993
/nl/subgraphs/cookbook/polymarket/
972994
/nl/subgraphs/cookbook/secure-api-keys-nextjs/
995+
/nl/subgraphs/cookbook/subgraph-composition-three-sources/
996+
/nl/subgraphs/cookbook/subgraph-composition/
973997
/nl/subgraphs/cookbook/subgraph-debug-forking/
974998
/nl/subgraphs/cookbook/subgraph-uncrashable/
975999
/nl/subgraphs/cookbook/transfer-to-the-graph/
@@ -1053,6 +1077,8 @@
10531077
/pl/subgraphs/cookbook/near/
10541078
/pl/subgraphs/cookbook/polymarket/
10551079
/pl/subgraphs/cookbook/secure-api-keys-nextjs/
1080+
/pl/subgraphs/cookbook/subgraph-composition-three-sources/
1081+
/pl/subgraphs/cookbook/subgraph-composition/
10561082
/pl/subgraphs/cookbook/subgraph-debug-forking/
10571083
/pl/subgraphs/cookbook/subgraph-uncrashable/
10581084
/pl/subgraphs/cookbook/transfer-to-the-graph/
@@ -1138,6 +1164,8 @@
11381164
/pt/subgraphs/cookbook/near/
11391165
/pt/subgraphs/cookbook/polymarket/
11401166
/pt/subgraphs/cookbook/secure-api-keys-nextjs/
1167+
/pt/subgraphs/cookbook/subgraph-composition-three-sources/
1168+
/pt/subgraphs/cookbook/subgraph-composition/
11411169
/pt/subgraphs/cookbook/subgraph-debug-forking/
11421170
/pt/subgraphs/cookbook/subgraph-uncrashable/
11431171
/pt/subgraphs/cookbook/transfer-to-the-graph/
@@ -1221,6 +1249,8 @@
12211249
/ro/subgraphs/cookbook/near/
12221250
/ro/subgraphs/cookbook/polymarket/
12231251
/ro/subgraphs/cookbook/secure-api-keys-nextjs/
1252+
/ro/subgraphs/cookbook/subgraph-composition-three-sources/
1253+
/ro/subgraphs/cookbook/subgraph-composition/
12241254
/ro/subgraphs/cookbook/subgraph-debug-forking/
12251255
/ro/subgraphs/cookbook/subgraph-uncrashable/
12261256
/ro/subgraphs/cookbook/transfer-to-the-graph/
@@ -1306,6 +1336,8 @@
13061336
/ru/subgraphs/cookbook/near/
13071337
/ru/subgraphs/cookbook/polymarket/
13081338
/ru/subgraphs/cookbook/secure-api-keys-nextjs/
1339+
/ru/subgraphs/cookbook/subgraph-composition-three-sources/
1340+
/ru/subgraphs/cookbook/subgraph-composition/
13091341
/ru/subgraphs/cookbook/subgraph-debug-forking/
13101342
/ru/subgraphs/cookbook/subgraph-uncrashable/
13111343
/ru/subgraphs/cookbook/transfer-to-the-graph/
@@ -1391,6 +1423,8 @@
13911423
/sv/subgraphs/cookbook/near/
13921424
/sv/subgraphs/cookbook/polymarket/
13931425
/sv/subgraphs/cookbook/secure-api-keys-nextjs/
1426+
/sv/subgraphs/cookbook/subgraph-composition-three-sources/
1427+
/sv/subgraphs/cookbook/subgraph-composition/
13941428
/sv/subgraphs/cookbook/subgraph-debug-forking/
13951429
/sv/subgraphs/cookbook/subgraph-uncrashable/
13961430
/sv/subgraphs/cookbook/transfer-to-the-graph/
@@ -1476,6 +1510,8 @@
14761510
/tr/subgraphs/cookbook/near/
14771511
/tr/subgraphs/cookbook/polymarket/
14781512
/tr/subgraphs/cookbook/secure-api-keys-nextjs/
1513+
/tr/subgraphs/cookbook/subgraph-composition-three-sources/
1514+
/tr/subgraphs/cookbook/subgraph-composition/
14791515
/tr/subgraphs/cookbook/subgraph-debug-forking/
14801516
/tr/subgraphs/cookbook/subgraph-uncrashable/
14811517
/tr/subgraphs/cookbook/transfer-to-the-graph/
@@ -1559,6 +1595,8 @@
15591595
/uk/subgraphs/cookbook/near/
15601596
/uk/subgraphs/cookbook/polymarket/
15611597
/uk/subgraphs/cookbook/secure-api-keys-nextjs/
1598+
/uk/subgraphs/cookbook/subgraph-composition-three-sources/
1599+
/uk/subgraphs/cookbook/subgraph-composition/
15621600
/uk/subgraphs/cookbook/subgraph-debug-forking/
15631601
/uk/subgraphs/cookbook/subgraph-uncrashable/
15641602
/uk/subgraphs/cookbook/transfer-to-the-graph/
@@ -1644,6 +1682,8 @@
16441682
/ur/subgraphs/cookbook/near/
16451683
/ur/subgraphs/cookbook/polymarket/
16461684
/ur/subgraphs/cookbook/secure-api-keys-nextjs/
1685+
/ur/subgraphs/cookbook/subgraph-composition-three-sources/
1686+
/ur/subgraphs/cookbook/subgraph-composition/
16471687
/ur/subgraphs/cookbook/subgraph-debug-forking/
16481688
/ur/subgraphs/cookbook/subgraph-uncrashable/
16491689
/ur/subgraphs/cookbook/transfer-to-the-graph/
@@ -1727,6 +1767,8 @@
17271767
/vi/subgraphs/cookbook/near/
17281768
/vi/subgraphs/cookbook/polymarket/
17291769
/vi/subgraphs/cookbook/secure-api-keys-nextjs/
1770+
/vi/subgraphs/cookbook/subgraph-composition-three-sources/
1771+
/vi/subgraphs/cookbook/subgraph-composition/
17301772
/vi/subgraphs/cookbook/subgraph-debug-forking/
17311773
/vi/subgraphs/cookbook/subgraph-uncrashable/
17321774
/vi/subgraphs/cookbook/transfer-to-the-graph/
@@ -1812,6 +1854,8 @@
18121854
/zh/subgraphs/cookbook/near/
18131855
/zh/subgraphs/cookbook/polymarket/
18141856
/zh/subgraphs/cookbook/secure-api-keys-nextjs/
1857+
/zh/subgraphs/cookbook/subgraph-composition-three-sources/
1858+
/zh/subgraphs/cookbook/subgraph-composition/
18151859
/zh/subgraphs/cookbook/subgraph-debug-forking/
18161860
/zh/subgraphs/cookbook/subgraph-uncrashable/
18171861
/zh/subgraphs/cookbook/transfer-to-the-graph/
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: Aggregate Data Using Subgraph Composition
3+
sidebarTitle: 'Build a Composable Subgraph with Multiple Subgraphs'
4+
---
5+
6+
Optimize your Subgraph by merging data from three independent, source Subgraphs into a single composable Subgraph to enhance data aggregation.
7+
8+
> Important Reminders:
9+
>
10+
> - Subgraph composition is built into the CLI, and you can deploy with [Subgraph Studio](https://thegraph.com/studio/).
11+
> - This feature requires `specVersion` 1.3.0.
12+
13+
## Overview
14+
15+
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.
16+
17+
## Prerequisites
18+
19+
To deploy **all** Subgraphs locally, you must have the following:
20+
21+
- A [Graph Node](https://github.com/graphprotocol/graph-node) instance running locally
22+
- An [IPFS](https://docs.ipfs.tech/) instance running locally
23+
- [Node.js](https://nodejs.org) and npm
24+
25+
## Get Started
26+
27+
The following guide provides examples for defining three source Subgraphs to create one powerful composed Subgraph.
28+
29+
### Specifics
30+
31+
- 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.
32+
- The examples below show how to import and extend the schema of another Subgraph to enhance its functionality.
33+
- Each source Subgraph is optimized with a specific entity.
34+
- 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.
35+
36+
### Step 1. Deploy Block Time Source Subgraph
37+
38+
This first source Subgraph calculates the block time for each block.
39+
40+
- It imports schemas from other Subgraphs and adds a `block` entity with a `timestamp` field, representing the time each block was mined.
41+
- It listens to time-related blockchain events (e.g., block timestamps) and processes this data to update the Subgraph's entities accordingly.
42+
43+
To deploy this Subgraph locally, run the following commands:
44+
45+
```bash
46+
npm install
47+
npm run codegen
48+
npm run build
49+
npm run create-local
50+
npm run deploy-local
51+
```
52+
53+
### Step 2. Deploy Block Cost Source Subgraph
54+
55+
This second source Subgraph indexes the cost of each block.
56+
57+
#### Key Functions
58+
59+
- It imports schemas from other Subgraphs and adds a `block` entity with cost-related fields.
60+
- 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.
61+
62+
To deploy this Subgraph locally, run the same commands as above.
63+
64+
### Step 3. Define Block Size in Source Subgraph
65+
66+
This third source Subgraph indexes the size of each block. To deploy this Subgraph locally, run the same commands as above.
67+
68+
#### Key Functions
69+
70+
- It imports existing schemas from other Subgraphs and adds a `block` entity with a `size` field representing each block's size.
71+
- 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.
72+
73+
### Step 4. Combine Into Block Stats Subgraph
74+
75+
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.
76+
77+
> Note:
78+
>
79+
> - Any change to a source Subgraph will likely generate a new deployment ID.
80+
> - Be sure to update the deployment ID in the data source address of the Subgraph manifest to take advantage of the latest changes.
81+
> - All source Subgraphs should be deployed before the composed Subgraph is deployed.
82+
83+
#### Key Functions
84+
85+
- It provides a consolidated data model that encompasses all relevant block metrics.
86+
- It combines data from three source Subgraphs, and provides a comprehensive view of block statistics, enabling more complex queries and analyses.
87+
88+
## Key Takeaways
89+
90+
- This powerful tool will scale your Subgraph development and allow you to combine multiple Subgraphs.
91+
- The setup includes the deployment of three source Subgraphs and one final deployment of the composed Subgraph.
92+
- This feature unlocks scalability, simplifying both development and maintenance efficiency.
93+
94+
## Additional Resources
95+
96+
- Check out all the code for this example in [this GitHub repo](https://github.com/isum/subgraph-composition-example).
97+
- To add advanced features to your Subgraph, check out [Subgraph advanced features](/developing/creating/advanced/).
98+
- To learn more about aggregations, check out [Timeseries and Aggregations](/subgraphs/developing/creating/advanced/#timeseries-and-aggregations).

0 commit comments

Comments
 (0)