Skip to main content
Version: v3.x (DDN)

Quickstart with Hasura DDN

In less than a minute and without needing a data source connection string, you can have a supergraph API running locally and deployed on Hasura DDN. Check out the video here.

Prerequisites

  1. Install the DDN CLI

    Simply run the installer script in your terminal:

    curl -L https://graphql-engine-cdn.hasura.io/ddn/cli/v4/get.sh | bash
  2. Install Docker (needed for local development)

    The Docker based workflow helps you iterate and develop locally without deploying any changes to Hasura DDN, making the development experience faster and your feedback loops shorter. You'll need Docker Compose v2.27.1 or later.

  3. Validate the installation

    You can verify that the DDN CLI is installed correctly by running:

    ddn doctor

Log in via the CLI

After you log in, the CLI will acknowledge your login and give you access to Hasura Cloud resources.

ddn auth login

Initialize a new supergraph in a new directory

Once you move into this new directory, you'll see your project's files scaffolded out for you by running ls.

ddn supergraph init mysupergraph
cd mysupergraph

Connect to data

From the dropdown, choose the hasura/postgres data connector and connect to our sample PostgreSQL database using this URL: postgresql://read_only_user:[email protected]:5432/v3-docs-sample-app

ddn connector init my_connector -i

Introspect your data source

This will create Hasura metadata describing the schema of your data source. After running this, you should see tables present in your app/connector/my_connector/configuration.json file, which you can open in your preferred editor.

ddn connector introspect my_connector

Add your resources

Create metadata for models, commands, and relationships in your supergraph. These define the structure, operations, and connections within your supergraph and are generated as Hasura Metadata Language (HML) present in your app/metadata directory.

ddn model add my_connector '*'
ddn command add my_connector '*'
ddn relationship add my_connector '*'

Build your supergraph

Create an immutable build of your supergraph and the local assets to run the engine. The build is stored as a set of JSON files in engine/build.

ddn supergraph build local

Start your supergraph

Start your engine, connector, and other services. You can see a list of all running services using docker ps.

ddn run docker-start

Open the console

In a new terminal tab open to the project's directory, open the console — Hasura DDN's GUI — so you can test out your API.

ddn console --local

Query your data

Execute this query via your console. You'll see a list of all users and their orders returned!

query UsersAndOrders{
users {
id
name
email
orders {
id
created_at
status
}
}
}

Create a Hasura DDN project

Provision a new project on Hasura DDN, which serves as the deployment environment for your supergraph. Once complete, the CLI will return the project's name.

ddn project init

Build and deploy your supergraph

When this process is complete, the CLI will return a link to the hosted API where you can run the same query as before.

That's it! you've created your very first, fully-functioning supergraph and deployed it to Hasura DDN 🎉

ddn supergraph build create

Next steps

What we've laid out above is the quickest way to get started with Hasura DDN. However, you have complete, granular control over each step in the process and can extend and customize your supergraph to fit your teams' needs. After deploying your first supergraph, take your next steps with Hasura DDN 👇