The subgraph for the QuestBook platform. We use the graph to collect index events from our smart contract to make data from them quick to access. Our graph is currently hosted on our own private graph-node
.
See here if you don't know what the graph is.
- Clone the repo
- Run
yarn
- Run a graph node locally, see here on how to do that. Simplest method would be to run a local graph node on Docker.
- We use mustache to template the subgraph yaml, in order to reduce repeating ourselves when deploying to different networks. To prepare the subgraph yaml for deployment on a network, run
NETWORK={network} yarn prepare-subgraph
.- Eg. to prepare for deployment on Rinkeby -- run
NETWORK=rinkeby yarn prepare-subgraph
- Eg. to prepare for deployment on Rinkeby -- run
- Finally to deploy on your local graph node, run
NETWORK=rinkeby GRAPH_NODE=http://localhost:8020 yarn deploy-subgraph
- Note: change
GRAPH_NODE
environment variable to the graph node of your choice's admin URL. Typically this will be on port8020
- Note: change
- To deploy multiple subgraphs at once, use the
deploy:all
script. Eg.NETWORK=all GRAPH_NODE=abcd.com yarn deploy:all
NETWORK=rinkeby,neon-devnet GRAPH_NODE=abcd.com yarn deploy:all
(deploys two subgraphs)
- Apart from cloning the repository & installing the dependies via yarn, you'll need to install postgres on your system. Refer here.
- Postgres is required by the "matchstick" library (testing lib for the graph) to enable building mock databases to run tests against
- Once postgres is installed -- run
yarn test
- Add the chain ID to the QB validator service:
- Edit the openapi yaml to add the new chain ID
- Run
yarn generate:types
- Add the chain ID to the
schema.graphql
file - Run
yarn codegen:validators
to update the validators from the validator service with the new chain ID
- Familiarity with Typescript (assemblyscript ideally)
- Some familiarity with GraphQL
- Some familiarity with what smart contracts are, what an ABI is, other general web3 lingo
- If this is the first graph you'll be contributing to, would recommend building a sample subgraph first. Refer here for the same.