The Graph Network > Developing

Developing

Reading time: 3 min

To start coding right away, go to Developer Quick Start.

Overview

Link to this section

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:

  1. Create, deploy, and publish subgraphs to The Graph using Graph CLI and Subgraph Studio.
  2. Use GraphQL to query existing subgraphs.

What is GraphQL?

Link to this section
  • GraphQL is the query language for APIs and a runtime for executing those queries with your existing data. The Graph uses GraphQL to query subgraphs.

Developer Actions

Link to this section
  • Query subgraphs built by other developers in The Graph Network 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.

Subgraph Specifics

Link to this section

What are subgraphs?

Link to this section

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.
  • subgraph.graphql: this GraphQL schema defines what data is stored for your subgraph, and how to query it via GraphQL.
  • mappings: this AssemblyScript mappings file translates data from the event data to the entities defined in your schema.

Learn the detailed specifics to create a subgraph.

Subgraph Lifecycle

Link to this section

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

Subgraph Lifecycle

Build locally

Link to this section

Great subgraphs start with a local development environment and unit tests. Developers use Graph CLI, a command-line interface tool for building and deploying subgraphs on The Graph. They can also use Graph TypeScript and Matchstick to create robust subgraphs.

Deploy to Subgraph Studio

Link to this section

Once defined, a subgraph can be deployed to Subgraph 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

Link to this section

When you're happy with your subgraph, you can publish it 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 by sending the NFT.
  • Published subgraphs have associated metadata, which provides other network participants with useful context and information.

Add Curation Signal for Indexing

Link to this section

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 on The Graph.

What is signal?

Link to this section
  • 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

Link to this section

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.

Learn more about querying subgraphs.

Updating Subgraphs

Link to this section

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 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.

Deprecating & Transferring Subgraphs

Link to this section

If you no longer need a published subgraph, you can deprecate or transfer it. Deprecating a subgraph returns any signaled GRT to Curators.

Edit page

Previous
Curating
Next
Graph Explorer
Edit page