This is a sample project generated by hydra-cli scaffold
. Experiment by modifying schema.graphql
and the mappings in the mappings
folder.
just up
just codegen
just build
just reset
just explore
Start processor
just process
Run GraphQL queries
just serve
- Node v14x
- Docker
# The dependencies setup relies on de-duplication, use `ci` to get everything right
npm ci
# Start a postgres instance
docker-compose up db # add optional -d flag to detach from terminal
# Apply migrations related to the processor's state keeping tables
npm run processor:migrate
# Apply the project's migrations
npm run db:migrate
# Now you can start processing chain data
npm run processor:start
# The above command will block
# Open a separate terminal and launch the graphql server to query the processed data
npm run query-node:start
Hydra tools expect a certain directory layout:
src/generated
- model/server definitions created bycodegen
. Do not alter the contents of this directory manually.src/server-extension
- module with customtype-graphql
based resolverssrc/types
- data type definitions for chain events and extrinsics created bytypegen
.src/mappings
- mapping module.lib
- compiled js files. The structure of this directory must reflectsrc
..env
- hydra tools are heavily driven by environment variables defined here or supplied by a shell.
If you do not plan to extend GraphQl server you can delete server-extension
module and then remove
type-graphql
and class-validator
dependencies.
If you modified schema.graphql
:
# Run codegen to re-generate model/server files
npm run codegen
# Analyze database state and create a new migration to match generated models
npm run db:create-migration # add -n "myName" to skip the migration name prompt
# Apply the migrations
npm run db:migrate
You might want update the Initial
migration instead of creating a new one (e.g. during the development phase when the production database is not yet set up). In that case it convenient to reset the database schema and start afresh:
rm db/migrations/LastUnappliedMigration.ts
npm run db:reset
npm run db:create-migration
npm run db:migrate
To generate new type definitions for chain events and extrinsics:
# Review typegen section of manifest.yml (https://docs.subsquid.io/hydra-typegen)
# Delete old definitions
rm -rf src/types
# Run typegen tool
npm run typegen
In case you just want to extend resolvers you don't index the whole project and just import the postgres database (last data 11.05.2022):
- Download the data
docker-compose up db
docker exec -it rubick-db-1 psql -U postgres -d postgres -c "CREATE DATABASE squid;"
docker exec -i rubick-db-1 psql -U postgres -d squid < rubick.sql
rubick-db-1
.
For more details, please check out https://docs.subsquid.io.