Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developing & Subgraphs #830

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
61 changes: 1 addition & 60 deletions website/pages/en/network/developing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,67 +23,8 @@ On The Graph, you can:
- Create custom subgraphs to fulfill specific data needs, allowing improved scalability and flexibility for other developers.
- Deploy, publish and signal your subgraphs within The Graph Network.

## Subgraph Specifics

### What are subgraphs?

A subgraph is a custom API built on blockchain data. It extracts data from a blockchain, processes it, and stores it so that it can be easily queried via GraphQL.

A subgraph primarily consists of the following files:

- `subgraph.yaml`: this YAML file contains the [subgraph manifest](/developing/creating-a-subgraph/#the-subgraph-manifest).
- `subgraph.graphql`: this GraphQL schema defines what data is stored for your subgraph, and how to query it via [GraphQL](/developing/creating-a-subgraph/#the-graphql-schema).
- `mappings`: this [AssemblyScript](https://github.com/AssemblyScript/assemblyscript) mappings file translates data from the event data to the entities defined in your schema.

Learn the detailed specifics to [create a subgraph](/developing/creating-a-subgraph/).

## Subgraph Lifecycle

Here is a general overview of a subgraph’s lifecycle:

![Subgraph Lifecycle](/img/subgraph-lifecycle.png)

### Build locally

Great subgraphs start with a local development environment and unit tests. Developers use [Graph CLI](https://github.com/graphprotocol/graph-tooling/tree/main/packages/cli), a command-line interface tool for building and deploying subgraphs on The Graph. They can also use [Graph TypeScript](/developing/graph-ts/) and [Matchstick](/developing/unit-testing-framework/) to create robust subgraphs.

### Deploy to Subgraph Studio

Once defined, a subgraph can be [deployed to Subgraph Studio](/deploying/deploying-a-subgraph-to-studio/). In Subgraph Studio, you can do the following:

- Use its staging environment to index the deployed subgraph and make it available for review.
- Verify that your subgraph doesn't have any indexing errors and works as expected.

### Publish to the Network

When you're happy with your subgraph, you can [publish it](/publishing/publishing-a-subgraph/) to The Graph Network.

- This is an on-chain action, which registers the subgraph and makes it discoverable by Indexers.
- Published subgraphs have a corresponding NFT, which defines the ownership of the subgraph. You can [transfer the subgraph's ownership](/managing/transfer-a-subgraph/) by sending the NFT.
- Published subgraphs have associated metadata, which provides other network participants with useful context and information.

### Add Curation Signal for Indexing

Published subgraphs are unlikely to be picked up by Indexers without curation signal. To encourage indexing you should add signal to your subgraph. Learn more about signaling and [curating](/network/curating/) on The Graph.

#### What is signal?

- Signal is locked GRT associated with a given subgraph. It indicates to Indexers that a given subgraph will receive query volume and it contributes to the indexing rewards available for processing it.
- Third party Curators may also signal on a given subgraph, if they deem the subgraph likely to drive query volume.

### Querying & Application Development

Subgraphs on The Graph Network receive 100,000 free queries per month, after which point developers can either [pay for queries with GRT or a credit card](/billing/).

Learn more about [querying subgraphs](/querying/querying-the-graph/).

### Updating Subgraphs

To update your subgraph with bug fixes or new functionalities, initiate a transaction to point it to the new version. You can deploy new versions of your subgraphs to [Subgraph Studio](https://thegraph.com/studio/) for development and testing.

- If you selected "auto-migrate" when you applied the signal, updating the subgraph will migrate any signal to the new version and incur a migration tax.
- This signal migration should prompt Indexers to start indexing the new version of the subgraph, so it should soon become available for querying.

### Deleting & Transferring Subgraphs

If you no longer need a published subgraph, you can [delete](/managing/delete-a-subgraph/) or [transfer](/managing/transfer-a-subgraph/) it. Deleting a subgraph returns any signaled GRT to [Curators](/network/curating/).
Check out the documentation on [subgraphs](/subgraphs/) to learn specifics.
51 changes: 48 additions & 3 deletions website/pages/en/subgraphs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ The **subgraph definition** consists of the following files:

To learn more about each subgraph component, check out [creating a subgraph](/developing/creating-a-subgraph/).

## Subgraph Lifecycle

Here is a general overview of a subgraph’s lifecycle:

![Subgraph Lifecycle](/img/subgraph-lifecycle.png)

## Subgraph Development

1. [Create a subgraph](/developing/creating-a-subgraph/)
Expand All @@ -34,8 +40,47 @@ To learn more about each subgraph component, check out [creating a subgraph](/de
4. [Publish a subgraph](/publishing/publishing-a-subgraph/)
5. [Signal on a subgraph](/publishing/publishing-a-subgraph/#adding-signal-to-your-subgraph)

## Subgraph Lifecycle
### Build locally

Here is a general overview of a subgraph’s lifecycle:
Great subgraphs start with a local development environment and unit tests. Developers use [Graph CLI](https://github.com/graphprotocol/graph-tooling/tree/main/packages/cli), a command-line interface tool for building and deploying subgraphs on The Graph. They can also use [Graph TypeScript](/developing/graph-ts/) and [Matchstick](/developing/unit-testing-framework/) to create robust subgraphs.

![Subgraph Lifecycle](/img/subgraph-lifecycle.png)
### Deploy to Subgraph Studio

Once defined, a subgraph can be [deployed to Subgraph Studio](/deploying/deploying-a-subgraph-to-studio/). In Subgraph Studio, you can do the following:

- Use its staging environment to index the deployed subgraph and make it available for review.
- Verify that your subgraph doesn't have any indexing errors and works as expected.

### Publish to the Network

When you're happy with your subgraph, you can [publish it](/publishing/publishing-a-subgraph/) to The Graph Network.

- This is an on-chain action, which registers the subgraph and makes it discoverable by Indexers.
idalithb marked this conversation as resolved.
Show resolved Hide resolved
- Published subgraphs have a corresponding NFT, which defines the ownership of the subgraph. You can [transfer the subgraph's ownership](/managing/transfer-a-subgraph/) by sending the NFT.
- Published subgraphs have associated metadata, which provides other network participants with useful context and information.

### Add Curation Signal for Indexing

Published subgraphs are unlikely to be picked up by Indexers without curation signal. To encourage indexing you should add signal to your subgraph. Learn more about signaling and [curating](/network/curating/) on The Graph.

#### What is signal?

- Signal is locked GRT associated with a given subgraph. It indicates to Indexers that a given subgraph will receive query volume and it contributes to the indexing rewards available for processing it.
- Third party Curators may also signal on a given subgraph, if they deem the subgraph likely to drive query volume.
idalithb marked this conversation as resolved.
Show resolved Hide resolved

### Querying & Application Development

Subgraphs on The Graph Network receive 100,000 free queries per month, after which point developers can either [pay for queries with GRT or a credit card](/billing/).

Learn more about [querying subgraphs](/querying/querying-the-graph/).

### Updating Subgraphs

To update your subgraph with bug fixes or new functionalities, initiate a transaction to point it to the new version. You can deploy new versions of your subgraphs to [Subgraph Studio](https://thegraph.com/studio/) for development and testing.

- If you selected "auto-migrate" when you applied the signal, updating the subgraph will migrate any signal to the new version and incur a migration tax.
- This signal migration should prompt Indexers to start indexing the new version of the subgraph, so it should soon become available for querying.

### Deleting & Transferring Subgraphs

If you no longer need a published subgraph, you can [delete](/managing/delete-a-subgraph/) or [transfer](/managing/transfer-a-subgraph/) it. Deleting a subgraph returns any signaled GRT to [Curators](/network/curating/).
Loading