Subgraphs

Reading time: 1 min

What is a Subgraph?

Link to this section

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

Subgraph Capabilities

Link to this section
  • Access Data: Subgraphs enable the querying and indexing of blockchain data for web3.
  • Build: Developers can build, deploy, and publish subgraphs to The Graph Network. To get started, check out the subgraph developer Quick Start.
  • Index & Query: Once a subgraph is indexed, anyone can query it. Explore and query all subgraphs published to the network in Graph Explorer.

Inside a Subgraph

Link to this section

The subgraph manifest, subgraph.yaml, defines the smart contracts & network your subgraph will index, the events from these contracts to pay attention to, and how to map event data to entities that Graph Node stores and allows to query.

The subgraph definition consists of the following files:

  • subgraph.yaml: Contains the subgraph manifest

  • schema.graphql: A GraphQL schema defining the data stored for your subgraph and how to query it via GraphQL

  • mapping.ts: AssemblyScript Mappings code that translates event data into entities defined in your schema

To learn more about each subgraph component, check out creating a subgraph.

Subgraph Development

Link to this section
  1. Create a subgraph
  2. Deploy a subgraph
  3. Test a subgraph
  4. Publish a subgraph
  5. Signal on a subgraph

Subgraph Lifecycle

Link to this section

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

Subgraph Lifecycle

Edit page

Previous
Quick Start
Next
Supported Networks
Edit page