You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/pages/en/developing/creating-a-subgraph.mdx
+35-2Lines changed: 35 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -752,6 +752,8 @@ dataSources:
752
752
753
753
The `indexerHints` setting in a subgraph's manifest provides directives for indexers on processing and managing a subgraph. It influences operational decisions across data handling, indexing strategies, and optimizations. Presently, it features the `prune` option for managing historical data retention or pruning.
754
754
755
+
> This feature is available from `specVersion: 1.0.0`
756
+
755
757
### Prune
756
758
757
759
`indexerHints.prune`: Defines the retention of historical block data for a subgraph. Options include:
@@ -765,9 +767,17 @@ The `indexerHints` setting in a subgraph's manifest provides directives for inde
765
767
prune: auto
766
768
```
767
769
768
-
> The term "history" in this context of subgraphs is about storing data that reflects the old states of mutable entities. This capability is essential for [time travel queries](/querying/graphql-api/#time-travel-queries), This feature enables querying the past states of these entities at specific blocks throughout the blockchain's history.
770
+
> The term "history" in this context of subgraphs is about storing data that reflects the old states of mutable entities.
771
+
772
+
History as of a given block is required for:
773
+
774
+
- [Time travel queries](/querying/graphql-api/#time-travel-queries), which enable querying the past states of these entities at specific blocks throughout the subgraph's history
775
+
- Using the subgraph as a [graft base](/developing/creating-a-subgraph/#grafting-onto-existing-subgraphs) in another subgraph, at that block
776
+
- Rewinding the subgraph back to that block
777
+
778
+
If historical data as of the block has been pruned, the above capabilities will not be available.
769
779
770
-
Using `"auto"` is generally recommended as it maximizes query performance and is sufficient for most users who do not require access to extensive historical data.
780
+
> Using `"auto"` is generally recommended as it maximizes query performance and is sufficient for most users who do not require access to extensive historical data.
771
781
772
782
For subgraphs leveraging [time travel queries](/querying/graphql-api/#time-travel-queries), it's advisable to either set a specific number of blocks for historical data retention or use `prune: never` to keep all historical entity states. Below are examples of how to configure both options in your subgraph's settings:
773
783
@@ -785,6 +795,29 @@ indexerHints:
785
795
prune: never
786
796
```
787
797
798
+
You can check the earliest block (with historical state) for a given subgraph by querying the [Indexing Status API](/deploying/deploying-a-subgraph-to-hosted/#checking-subgraph-health):
799
+
800
+
```
801
+
{
802
+
indexingStatuses(subgraphs: ["Qm..."]) {
803
+
subgraph
804
+
synced
805
+
health
806
+
chains {
807
+
earliestBlock {
808
+
number
809
+
}
810
+
latestBlock {
811
+
number
812
+
}
813
+
chainHeadBlock { number }
814
+
}
815
+
}
816
+
}
817
+
```
818
+
819
+
Note that the `earliestBlock` is the earliest block with historical data, which will be more recent than the `startBlock` specified in the manifest, if the subgraph has been pruned.
820
+
788
821
## Event Handlers
789
822
790
823
Event handlers in a subgraph react to specific events emitted by smart contracts on the blockchain and trigger handlers defined in the subgraph's manifest. This enables subgraphs to process and store event data according to defined logic.
0 commit comments