Hasura configuration tool
For info on migrating to
@subsquid/hasura-configuration>=2.0.0 see this page.@subsquid/hasura-configuration is a tool for managing Hasura configuration in PostgreSQL-powered squids. Install it with
HASURA_GRAPHQL_ENDPOINTfor Hasura URL (defaults tohttp://localhost:8080).HASURA_GRAPHQL_ADMIN_SECRETfor admin access (only required to usesquid-hasura-configuration apply).- If your Hasura instance(s) use a role other than
publicto serve the anonymous part of your API, also setHASURA_GRAPHQL_UNAUTHORIZED_ROLE.
Generating the initial configuration
The tool uses your squid’s TypeORM models as input when generating the initial configuration. Make sure they are up to date. When done, runhasura_metadata.json. It enables:
- tracking all tables that correspond to schema entities;
SELECTpermissions for thepublic(or$HASURA_GRAPHQL_UNAUTHORIZED_ROLEif it is defined) role for all columns in these tables;- tracking all entity relationships.
Applying the configuration
Make sure your database is up, your Hasura instance is connected to it and the schema is up to date. If necessary, apply the migrations:Persisting configuration changes
When running a squid with a dedicated Hasura instance you will notice that squid resetting operations (docker compose down; docker compose up -d and sqd deploy -r) restore your Hasura API to its non-configured state. As you develop your API further you may want to persist your changes. squid-hasura-configuration helps with that by being compatible with the Settings > Metadata Actions > Import/Export metadata functions of the web GUI.
Any extra configuration you may make via the web GUI or Hasura metadata API can be persisted by exporting the metadata to hasura_metadata.json via the Export metadata function, then applying it to blank Hasura instances with

