Skip to main content
Version: v3.x

Upgrading to context config v3

What has happened?

A new revision (v2.5.0) of the DDN CLI has been released with enhancements to the context config. This update introduces a powerful new scripting feature, allowing users to define and execute custom scripts directly from their context configuration.

What has changed?

  • The project's context config is bumped from v2 to v3
  • A new scripts field has been introduced in the context configuration.
  • The CLI now supports running custom scripts with environment detection.

Scripting Feature

The new scripting feature allows you to define custom scripts in your context configuration. These scripts can be executed with ddn run command, and the CLI will automatically detect your environment to run the appropriate version of the script. Here's an example of the new context configuration structure:

kind: Context
version: v3
definition:
current: default
contexts:
default:
supergraph: ../supergraph.yaml
subgraph: ../app/subgraph.yaml
localEnvFile: ../.env
scripts:
docker-start:
bash: HASURA_DDN_PAT=$(ddn auth print-pat) docker compose --env-file .env up --build --pull always -d
powershell: $Env:HASURA_DDN_PAT = (ddn auth print-pat); docker compose --env-file .env up --build --pull always -d

Running Scripts

To run a script, use the command:

ddn run docker-start

Multi-Platform Support

You can define scripts for bash and PowerShell under a single script name. DDN CLI will automatically select the correct script version based on your environment.

Custom Scripts

You're free to create your own scripts tailored to your workflow needs. This allows you to encapsulate complex command sequences into simple, memorable script names.

Paths in scripts are relative to your project's root path.

Backwards Compatibility

Please note that context configuration v2 is still fully supported. While we encourage you to upgrade to v3 to take advantage of the new scripting features, you can continue to use v2 configurations without any issues.

Migrate an existing project

To start using this new feature in an existing project:

  1. Update your CLI to the latest version.
ddn update-cli
  1. Run codemod from Hasura project directory to update your project context configuration to v3.
ddn codemod upgrade-context-v2-to-v3 --dir .
  1. By default, we add a docker-start script for you so that you can just run ddn run docker-start to get the local local supergraph and connectors running using Docker

Creating and running a custom script

Add this under your context configuration's script field:

my-custom-script:
bash: echo "Hello from bash!"
powershell: Write-Host "Hello from PowerShell!"

Then run it using:

ddn run my-custom-script

Need help?

If you need help migrating your project or have any other questions please reach out to us on our Discord.

Legacy project structure

See the legacy context config structure before this update below.

kind: Context
version: v2
definition:
current: default
contexts:
default:
project: emerging-stag-9129
supergraph: ../supergraph.yaml
subgraph: ../app/subgraph.yaml
localEnvFile: ../.env
cloudEnvFile: ../.env.cloud
Loading...