Skip to content

Latest commit

 

History

History

sample

Sample Hydra Project

This is a sample project similar to the one generated by hydra-cli scaffold. By default, it runs against a public Kusama Indexer endpoint.

Experiment by modifying schema.graphql and the mapping files in the mappings folder.

Codegen

Run

yarn codegen

to generate the model files as defined in schema.graphql

Codegen for event types

A separate tool Hydra Typegen can be used for generating Typescript classes for the event handlers (the mappings).
Run

yarn typegen

to run the typegen for events and extrinsics defined in typegen.yml (by default, it fetches the metadata from a substrate node run at localhost).

DB Migrations

Inspect the DB settings in .env and prepare run the database migrations:

yarn db:prepare
yarn db:migrate

Note, that any schema changes in schema.graphql would require a fresh database. You may drop the old one database and rerun the model generation and schema migrations using a single command

yarn rebuild

NB! Don't use in production, as it will delete all the existing records.

Run the processor and the GraphQL server

Then run the processor:

yarn processor:start

and the GraphQL server (opens a GraphQL playground at localhost by default):

yarn query-node:start:dev

Locally run indexer and indexer-gateway

Run

yarn indexer:start:dev

It will build local images for hydra-indexer and hydra-indexer-gateway and run the docker-compose stack defined in docker-compose-indexer-dev.yml

To run the processor against the local indexer, make sure INDEXER_ENDPOINT_URL is set to the local indexer-gateway (http://localhost:4001/graphql by default).

Custom chains

If there is no public Hydra Indexer readily available, one should set-up a self-hosted indexer and indexer-api-gateway. The simplest way is set it up is to run pre-built docker images for indexer and indexer-api-gateway as defined in docker-compose.yml.