Local subgraphs
There are situations where you may choose to run a subgraph locally rather than through a hosted infrastructure provider. Perhaps you want to have direct access to the Postgres database holding the subgraph entities, perhaps you want to self host during development or perhaps you want to use your own infrastructure as a fail-over solution. Whatever the reason, the steps below can be followed to self host your subgraphs developed for hosted providers including thegraph and Goldsky.
Start by coning the graph-node repository.
git clone https://github.com/graphprotocol/graph-node.git
Edit docker/docker-compose.yml and set an archive node.
environment:\
ethereum: 'mainnet: [https://archive.moksha.vana.org](https://archive.moksha.vana.org)
Deploy the three containers (ipfs, postgress, thegraph).
docker-compose up
Once you have finished with the environment you can take the containers back down.
docker-compose down -v
With the infrastructure deployed and running locally, you can now deploy your subgraph.
graph deploy --node http://localhost:8020 --ipfs http\://localhost:5001 moksha
With your subgraph deployed and indexing, you can track the progress of the indexing in the local GraphQL playground.
http://localhost:8030/graphql/playground
Here you can run a query for the status of the subgraph.
{
indexingStatuses(subgraphs: ["moksha"]) {
subgraph
synced
health
fatalError {
message
handler
}
chains {
network
chainHeadBlock {
number
}
earliestBlock {
number
}
latestBlock {
number
}
}
}
}
More generally you will want to run queries against the subgraph the same as you would with thegraph or Goldsky which you can do through the locally running GraphQL studio.
http://localhost:8000/subgraphs/name/moksh

Updated 18 days ago