Skip to main content
Version: v2.x

Hasura CLI Configuration Reference

Introduction

When using the Hasura CLI, you'll pass various values to different commands. These values can be configured using:

  • a configuration file
  • a .env file
  • environment variables
  • flags to the command itself
Note

The order of precedence by which the CLI processes these values is flag -> environment variables -> .env file values -> configuration file values -> default.

In the sections below, we'll explain how to configure the CLI for each of these use cases.

Configuration file

For the Hasura CLI to work, the config.yaml file is required and created automatically when running the hasura init command. You can configure the configuration file with the following config keys:

version:
endpoint:
admin_secret:
admin_secrets:
insecure_skip_tls_verify:
certificate_authority:
access_key: #deprecated
api_paths:
query:
graphql:
config:
pg_dump:
version:
metadata_directory:
migrations_directory:
seeds_directory:
actions:
kind:
handler_webhook_baseurl:
codegen:
framework:
output_dir:
uri:
Config KeyRequiredSupported since Config VersionDefault value
versionfalse13
endpointtrue1http://localhost:8080
admin_secretfalse1
admin_secretsfalse3 (added in v2.8.0)
access_keyfalse1 (Deprecated)
insecure_skip_tls_verifyfalse1 (added in v1.2.0)false
certificate_authorityfalse1 (added in v1.2.0)
api_pathsfalse1
api_paths.queryfalse1v1/query
api_paths.graphqlfalse1v1/graphql
api_paths.configfalse1v1alpha1/config
api_paths.pg_dumpfalse1v1alpha1/pg_dump
api_paths.versionfalse1v1/version
metadata_directoryfalse2
migrations_directoryfalse1migrations
seeds_directoryfalse2
actionsfalse2
actions.kindtrue2synchronous
actions.handler_webhook_baseurltrue2http://localhost:3000
actions.codegenfalse2
actions.codegen.frameworktrue2
actions.codegen.output_dirtrue2
actions.codegen.urifalse2
Note

The above structure is for the config v3 file which is supported since v2.0.0-alpha.1. Refer to this page on how to upgrade to config v2.

A .env file

Alternatively, the Hasura CLI can also read environment variables from a .env file, created manually by the user, at the project's root directory. A global flag, --envfile, is available to explicitly identify the .env file which defaults to .env if you don't provide it.

It's important to note that this will not override an environment variable that already exists.

As an example, the command below will read environment variables from the production.env file present at the project's root directory.

hasura console --envfile production.env
Supported from

.env file is supported in versions v1.2.0 and above.

Environment variables

The following environment variables can be utilized to configure different values on a per-project basis for use with the CLI:

Environment variableConfig file keyDescription
HASURA_GRAPHQL_VERSIONversionConfig version to be used.
HASURA_GRAPHQL_ENDPOINTendpointhttp(s) endpoint for Hasura GraphQL Engine.
HASURA_GRAPHQL_ADMIN_SECRETadmin_secretAdmin secret for Hasura GraphQL Engine.
HASURA_GRAPHQL_ADMIN_SECRETSadmin_secretsAdmin secrets for Hasura GraphQL Engine (Cloud/Enterprise Edition only). eg: HASURA_GRAPHQL_ADMIN_SECRETS='["foo", "bar", "baz"]'
HASURA_GRAPHQL_ACCESS_KEYaccess_keyAccess key for Hasura GraphQL Engine. Note: Deprecated. Use admin secret instead.
HASURA_GRAPHQL_INSECURE_SKIP_TLS_VERIFYinsecure_skip_tls_verifySkip verifying SSL certificate for the Hasura endpoint. Useful if you have a self-singed certificate and don't have access to the CA cert.
HASURA_GRAPHQL_CERTIFICATE_AUTHORITYcertificate_authorityPath to the CA certificate for validating the self-signed certificate for the Hasura endpoint.
HASURA_GRAPHQL_API_PATHS_QUERYapi_paths.querySchema/ Metadata API endpoint. More details at Schema / Metadata API (Deprecated).
HASURA_GRAPHQL_API_PATHS_GRAPHQLapi_paths.graphqlGraphQL API endpoint. More details at GraphQL API.
HASURA_GRAPHQL_API_PATHS_CONFIGapi_paths.configConfig API endpoint. More details at Config API`.
HASURA_GRAPHQL_API_PATHS_PG_DUMPapi_paths.pg_dumpPG Dump API endpoint. More details at pg_dump API.
HASURA_GRAPHQL_API_PATHS_VERSIONapi_paths.versionVersion API endpoint. More details at RESTified GraphQL API.
HASURA_GRAPHQL_METADATA_DIRECTORYmetadata_directoryDefines the directory where the Metadata files were stored.
HASURA_GRAPHQL_MIGRATIONS_DIRECTORYmigrations_directoryDefines the directory where the migration files were stored.
HASURA_GRAPHQL_SEEDS_DIRECTORYseeds_directoryDefines the directory where the seed files were stored.
HASURA_GRAPHQL_ACTIONS_KINDactions.kindKind to be used for actions.
HASURA_GRAPHQL_ACTIONS_HANDLER_WEBHOOK_BASEURLactions.handler_webhook_baseurlWebhook baseurl to be used for actions.
HASURA_GRAPHQL_ACTIONS_CODEGEN_FRAMEWORKactions.codegen.frameworkFramework to codegen for actions.
HASURA_GRAPHQL_ACTION_CODEGEN_OUTPUT_DIRactions.codegen.output_dirDefines the directory to create the codegen files.
HASURA_GRAPHQL_ACTION_CODEGEN_URIactions.codegen.uriURI to codegen for actions.

Flags

The keys in the previous section can be set using command line flags. The corresponding flag, for the environment variable or the configuration keys, can be found in the respective commands reference manual.

As an example, the --endpoint flag can be used to set the HASURA_GRAPHQL_ENDPOINT environment variable:

hasura metadata apply --endpoint "https://my-project.hasura.app"