Sample Hydra Project
This is a sample project generated by hydra-cli scaffold. Experiment by modifying schema.graphql and the mappings in the mappings folder.
Prerequisites
Node v14x
Docker
Bootstrap
npm install
# make sure dependencies are deduped, this is important
npm dedupe
# generate TypeScript definitions for substrate types
npm run typegen
# Analyze schema.graphql and generate model/server files
npm run codegen
# Start postgres instance
docker-compose up -d
# Apply migrations related to processor's state keeping tables
npm run processor:migrate
# Analyze database state and create migration to match generated models
npm run db:create-migration
# Apply pending migrations
npm run db:migrate
# Now you can start processing chain data
npm run processor:start
# The above command will block
# Open separate terminal and launch graphql server to query the processed data
npm run query-node:startProject structure
Hydra tools expect a certain directory layout explained here.
generated- model/server definitions generated bycodegen. Do not alter the contents of this directory.server-extension- a place for custom data models and resolvers defined via.model.ts,.resolver.tsfiles.chain- data type definitions for chain events and extrinsics generated bytypegen,overridable via
manifest.yml.mappings- mapping definitions, overridable viamanifest.yml..env- hydra tools are heavily driven by environment variables defined here.
Self-hosted indexer
It is recommeded to use already set up indexer if available, as new indexer typically requires some time to catch up with interesting events.
Have a look at ./indexer/docker-compose.yml for example of how you can set up a self-hosted version.
Last updated
Was this helpful?