Developing
Reading time: 3 min
To start coding right away, go to .
As a developer, you need data to build and power your dapp. Querying and indexing blockchain data is challenging, but The Graph provides a solution to this issue.
On The Graph, you can:
- Create, deploy, and publish subgraphs to The Graph using Graph CLI and .
- Use GraphQL to query existing subgraphs.
- is the query language for APIs and a runtime for executing those queries with your existing data. The Graph uses GraphQL to query subgraphs.
- Query subgraphs built by other developers in and integrate them into your own dapps.
- 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.
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.graphql
: this GraphQL schema defines what data is stored for your subgraph, and how to query it via .mappings
: this mappings file translates data from the event data to the entities defined in your schema.
Learn the detailed specifics to .
Here is a general overview of a subgraph’s lifecycle:
Great subgraphs start with a local development environment and unit tests. Developers use , a command-line interface tool for building and deploying subgraphs on The Graph. They can also use and to create robust subgraphs.
Once defined, a subgraph can be . 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.
When you're happy with your subgraph, you can 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 by sending the NFT.
- Published subgraphs have associated metadata, which provides other network participants with useful context and information.
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 on The Graph.
- 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.
Subgraphs on The Graph Network receive 100,000 free queries per month, after which point developers can either .
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 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.
If you no longer need a published subgraph, you can or it. Deprecating a subgraph returns any signaled GRT to .