Mokhtar Naamani 2f05da0c6d types v0.17.2 | 2 سال پیش | |
---|---|---|
.. | ||
codegen | 2 سال پیش | |
mappings | 2 سال پیش | |
schemas | 2 سال پیش | |
.gitignore | 3 سال پیش | |
README.md | 3 سال پیش | |
build.sh | 2 سال پیش | |
kill.sh | 3 سال پیش | |
manifest.yml | 3 سال پیش | |
package.json | 2 سال پیش | |
start.sh | 3 سال پیش |
This is a query-node project generated by hydra-cli
. Experiment by modifying schema.graphql
and the mappings in the mappings
folder, defined in manifest.yml
.
Run
yarn && yarn bootstrap
and generate the model files as defined in schema.graphql
, create the database and run all the necessary migrations in one shot.
NB! Don't use in production, as it will delete all the existing records.
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 manifest.yml
(it fetches the metadata from an RPC endpoint and blockhash defined there).
Mappings is a separated TypeScript module created in the mappings folder. The handlers exported by the module should match the ones defined in manifest.yml
in the mappings section. Once the necessary files are generated, build it with
yarn mappings:build
Then run the processor:
yarn processor:start
Afterwards start the GraphQL server in a separate terminal (opens a GraphQL playground at localhost by default):
yarn query-node:start:dev
The Hydra Indexer endpoint used by Hydra processor is defined as environment variable INDEXER_ENDPOINT_URL
sourced from .env
. There are publicly available Hydra indexers for Polkadot and Subsocial. For other chains, a self-hosted indexer should be used.
The simplest way to run an indexer locally is to run docker-compose-indexer.yml
with docker-compose
. The following environment variables must be provided:
Follow the links for more information about the indexer service and indexer-api-gateway.
Query node's user interface, GraphQL Playground, is expecting to be served at /graphql
.
If you are serving the files on path like /query/server/graphql
via some nginx proxy, aliasing, etc. you will need to provide
the base url to query node server via GRAPHQL_PLAYGROUND_CDN
environment variable.
# use the following when serving playground at `/query/server/graphql`
GRAPHQL_PLAYGROUND_CDN="query/server" yarn workspace query-node-root query-node:start:dev