Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions website/src/pages/en/subgraphs/best-practices/pruning.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebarTitle: 'Pruning with indexerHints'

## TLDR

[Pruning](/developing/creating-a-subgraph/#prune) removes archival entities from the Subgraph’s database up to a given block, and removing unused entities from a Subgraph’s database will improve a Subgraph’s query performance, often dramatically. Using `indexerHints` is an easy way to prune a Subgraph.
[Pruning](/subgraphs/developing/creating/subgraph-manifest/#prune) removes archival entities from the Subgraph’s database up to a given block, and removing unused entities from a Subgraph’s database will improve a Subgraph’s query performance, often dramatically. Using `indexerHints` is an easy way to prune a Subgraph.

## How to Prune a Subgraph With `indexerHints`

Expand All @@ -15,7 +15,7 @@ Add a section called `indexerHints` in the manifest.

- `prune: auto`: Retains the minimum necessary history as set by the Indexer, optimizing query performance. This is the generally recommended setting and is the default for all Subgraphs created by `graph-cli` >= 0.66.0.
- `prune: <Number of blocks to retain>`: Sets a custom limit on the number of historical blocks to retain.
- `prune: never`: No pruning of historical data; retains the entire history and is the default if there is no `indexerHints` section. `prune: never` should be selected if [Time Travel Queries](/subgraphs/querying/graphql-api/#time-travel-queries) are desired.
- `prune: never`: No pruning of historical data; retains the entire history and is the default if there is no `indexerHints` section. `prune: never` should be selected if [Time Travel Queries](/subgraphs/querying/graphql-api/#time-travel-queries-example) are desired.

We can add `indexerHints` to our Subgraphs by updating our `subgraph.yaml`:

Expand All @@ -33,7 +33,7 @@ dataSources:

## Important Considerations

- If [Time Travel Queries](/subgraphs/querying/graphql-api/#time-travel-queries) are desired as well as pruning, pruning must be performed accurately to retain Time Travel Query functionality. Due to this, it is generally not recommended to use `indexerHints: prune: auto` with Time Travel Queries. Instead, prune using `indexerHints: prune: <Number of blocks to retain>` to accurately prune to a block height that preserves the historical data required by Time Travel Queries, or use `prune: never` to maintain all data.
- If [Time Travel Queries](/subgraphs/querying/graphql-api/#time-travel-queries-example) are desired as well as pruning, pruning must be performed accurately to retain Time Travel Query functionality. Due to this, it is generally not recommended to use `indexerHints: prune: auto` with Time Travel Queries. Instead, prune using `indexerHints: prune: <Number of blocks to retain>` to accurately prune to a block height that preserves the historical data required by Time Travel Queries, or use `prune: never` to maintain all data.

- It is not possible to [graft](/subgraphs/cookbook/grafting/) at a block height that has been pruned. If grafting is routinely performed and pruning is desired, it is recommended to use `indexerHints: prune: <Number of blocks to retain>` that will accurately retain a set number of blocks (e.g., enough for six months).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ File data sources are a new Subgraph functionality for accessing off-chain data

Rather than fetching files "in line" during handler execution, this introduces templates which can be spawned as new data sources for a given file identifier. These new data sources fetch the files, retrying if they are unsuccessful, running a dedicated handler when the file is found.

This is similar to the [existing data source templates](/developing/creating-a-subgraph/#data-source-templates), which are used to dynamically create new chain-based data sources.
This is similar to the [existing data source templates](/subgraphs/developing/creating/subgraph-manifest/#data-source-templates), which are used to dynamically create new chain-based data sources.

> This replaces the existing `ipfs.cat` API

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Explore additional [resources for APIs](/subgraphs/developing/creating/graph-ts/

| Version | Release notes |
| :-: | --- |
| 1.2.0 | Added support for [Indexed Argument Filtering](/#indexed-argument-filters--topic-filters) & declared `eth_call` |
| 1.1.0 | Supports [Timeseries & Aggregations](#timeseries-and-aggregations). Added support for type `Int8` for `id`. |
| 1.0.0 | Supports [`indexerHints`](/developing/creating-a-subgraph/#indexer-hints) feature to prune Subgraphs |
| 1.2.0 | Added support for [Indexed Argument Filtering](/subgraphs/developing/creating/advanced/#indexed-argument-filters--topic-filters) & declared `eth_call` |
| 1.1.0 | Supports [Timeseries & Aggregations](/subgraphs/developing/creating/advanced/#timeseries-and-aggregations). Added support for type `Int8` for `id`. |
| 1.0.0 | Supports [`indexerHints`](/subgraphs/developing/creating/subgraph-manifest/#indexer-hints) feature to prune Subgraphs |
| 0.0.9 | Supports `endBlock` feature |
| 0.0.8 | Added support for polling [Block Handlers](/developing/creating-a-subgraph/#polling-filter) and [Initialisation Handlers](/developing/creating-a-subgraph/#once-filter). |
| 0.0.7 | Added support for [File Data Sources](/developing/creating-a-subgraph/#file-data-sources). |
| 0.0.8 | Added support for polling [Block Handlers](/subgraphs/developing/creating/subgraph-manifest/#polling-filter) and [Initialisation Handlers](/subgraphs/developing/creating/subgraph-manifest/#once-filter). |
| 0.0.7 | Added support for [File Data Sources](/subgraphs/developing/creating/advanced/#ipfsarweave-file-data-sources). |
| 0.0.6 | Supports fast [Proof of Indexing](/indexing/overview/#what-is-a-proof-of-indexing-poi) calculation variant. |
| 0.0.5 | Added support for event handlers having access to transaction receipts. |
| 0.0.4 | Added support for managing subgraph features. |
6 changes: 3 additions & 3 deletions website/src/pages/en/subgraphs/developing/developer-faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Within a Subgraph, the events are always processed in the order they appear in t

Templates allow you to create data sources quickly, while your Subgraph is indexing. Your contract might spawn new contracts as people interact with it. Since you know the shape of those contracts (ABI, events, etc.) upfront, you can define how you want to index them in a template. When they are spawned, your Subgraph will create a dynamic data source by supplying the contract address.

Check out the "Instantiating a data source template" section on: [Data Source Templates](/developing/creating-a-subgraph/#data-source-templates).
Check out the "Instantiating a data source template" section on: [Data Source Templates](/subgraphs/developing/creating/subgraph-manifest/#data-source-templates).

### 11. Is it possible to set up a Subgraph using `graph init` from `graph-cli` with two contracts? Or should I manually add another dataSource in `subgraph.yaml` after running `graph init`?

Expand Down Expand Up @@ -108,11 +108,11 @@ Yes. Sepolia supports block handlers, call handlers and event handlers. It shoul

### 19. Is it possible to specify what block to start indexing on?

Yes. `dataSources.source.startBlock` in the `subgraph.yaml` file specifies the number of the block that the dataSource starts indexing from. In most cases, we suggest using the block where the contract was created: [Start blocks](/developing/creating-a-subgraph/#start-blocks)
Yes. `dataSources.source.startBlock` in the `subgraph.yaml` file specifies the number of the block that the dataSource starts indexing from. In most cases, we suggest using the block where the contract was created: [Start blocks](/subgraphs/developing/creating/subgraph-manifest/#start-blocks)

### 20. What are some tips to increase the performance of indexing? My Subgraph is taking a very long time to sync

Yes, you should take a look at the optional start block feature to start indexing from the block where the contract was deployed: [Start blocks](/developing/creating-a-subgraph/#start-blocks)
Yes, you should take a look at the optional start block feature to start indexing from the block where the contract was deployed: [Start blocks](/subgraphs/developing/creating/subgraph-manifest/#start-blocks)

### 21. Is there a way to query the Subgraph directly to determine the latest block number it has indexed?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The standardized schemas each cover one protocol category. Every schema shares a

Because the schemas are meant to be consumed the same way regardless of protocol, they follow a consistent set of conventions.

**Three ways to read quantitative data.** You can query an entity directly for _real-time_ values (e.g. `totalValueLockedUSD` on a `Pool`), use [time-travel queries](https://thegraph.com/docs/en/subgraphs/querying/graphql-api/#time-travel-queries) for _point-in-time_ historical values, or query the snapshot entities for _time-series_ data (e.g. `PoolDailySnapshot`).
**Three ways to read quantitative data.** You can query an entity directly for _real-time_ values (e.g. `totalValueLockedUSD` on a `Pool`), use [time-travel queries](https://thegraph.com/docs/en/subgraphs/querying/graphql-api/#time-travel-queries-example) for _point-in-time_ historical values, or query the snapshot entities for _time-series_ data (e.g. `PoolDailySnapshot`).

**Standardized financial metrics.** Revenue is split consistently across every schema:

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/en/subgraphs/guides/enums.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum TokenStatus {

This means that when you use the `TokenStatus` type in your schema, you expect it to be exactly one of predefined values: `OriginalOwner`, `SecondOwner`, or `ThirdOwner`, ensuring consistency and validity.

To learn more about enums, check out [Creating a Subgraph](/developing/creating-a-subgraph/#enums) and [GraphQL documentation](https://graphql.org/learn/schema/#enumeration-types).
To learn more about enums, check out [Creating a Subgraph](/subgraphs/developing/creating/ql-schema/#enums) and [GraphQL documentation](https://graphql.org/learn/schema/#enumeration-types).

## Benefits of Using Enums

Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/en/subgraphs/guides/grafting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The grafted Subgraph can use a GraphQL schema that is not identical to the one o

For more information, you can check:

- [Grafting](/developing/creating-a-subgraph/#grafting-onto-existing-subgraphs)
- [Grafting](/subgraphs/developing/creating/advanced/#grafting-onto-existing-subgraphs)

In this tutorial, we will be covering a basic use case. We will replace an existing contract with an identical contract (with a new address, but the same code). Then, graft the existing Subgraph onto the "base" Subgraph that tracks the new contract.

Expand Down Expand Up @@ -197,6 +197,6 @@ If you want more experience with grafting, here are a few examples for popular c
- [ERC-721](https://github.com/messari/subgraphs/blob/master/subgraphs/erc721-metadata/subgraph.yaml)
- [Uniswap](https://github.com/messari/subgraphs/blob/master/subgraphs/uniswap-v3-forks/protocols/uniswap-v3/config/templates/uniswapV3Template.yaml),

To become even more of a Graph expert, consider learning about other ways to handle changes in underlying datasources. Alternatives like [Data Source Templates](/developing/creating-a-subgraph/#data-source-templates) can achieve similar results
To become even more of a Graph expert, consider learning about other ways to handle changes in underlying datasources. Alternatives like [Data Source Templates](/subgraphs/developing/creating/subgraph-manifest/#data-source-templates) can achieve similar results

> Note: A lot of material from this article was taken from the previously published [Arweave article](/subgraphs/cookbook/arweave/)
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ type TokenLockMetadata @entity {
export function handleMetadata(content: Bytes): void {
// dataSource.stringParams() returns the File DataSource CID
// stringParam() will be mocked in the handler test
// for more info https://thegraph.com/docs/en/developing/creating-a-subgraph/#create-a-new-handler-to-process-files
// for more info https://thegraph.com/docs/en/subgraphs/developing/creating/advanced/#create-a-new-handler-to-process-files
let tokenMetadata = new TokenLockMetadata(dataSource.stringParam())
const value = json.fromBytes(content).toObject()

Expand Down
Loading