The Subgraphs are essential for querying blockchain data efficiently, enabling dApps to fetch and display data seamlessly. This guide is designed to help you create and deploy a subgraph your network built by Thanos Stack. This step-by-step tutorial will walk you through the prerequisites, setup, and deployment process to get your graph node.
Prerequisites:
Install graph-cli: Ensure you have graph-cli version 0.31.0 or higher installed, as it's essential for managing subgraphs.
# install
## latest version 0.90.1 (2024-12-04)
npm install -g @graphprotocol/graph-cli
Range
<https://$>{graph-node endpoint}/deploy
<https://$>{graph-node endpoint}/deploy/*
<https://$>{ipfs endpoint}
<https://$>{ipfs endpoint}/*
Define Network Endpoints:
https://{graph-node endpoint}/deployhttps://{ipfs endpoint}Workflow Overview:
Navigate to your subgraph's root directory and run:
cd <YOUR_SUBGRAPH_ROOTPATH>
graph codegen
This command generates the necessary code in a generated directory. You can specify a different output directory if needed.
Compile your subgraph by executing:
graph build
This step ensures that your subgraph is ready for deployment.
Register your subgraph with the Graph Node:
graph create --node https://{graph-node endpoint} {subgraph-name}
Replace {subgraph-name} with your desired subgraph identifier.
Deploy your subgraph to the specified Graph Node:
graph deploy --node https://{graph-node endpoint} --ipfs https://{ipfs endpoint} {subgraph-name}
Ensure that the network name in your subgraph configuration is set to match the network name in your helm value file.