How to Create a Subgraph
Introduction
You can easily create subgraphs using the CLI and — for cloud projects — the Hasura DDN console. By default, the CLI
will generate an app subgraph when a new project is initialized.
In your local metadata
Within a local project directory, run the following:
ddn subgraph init <subgraph-name>
You can verify this by identifying the new subdirectory in your project with the subgraph's name.
Then, add the subgraph to your supergraph's config file:
ddn subgraph add <subgraph-name> --subgraph ./<subgraph-name>/subgraph.yaml --target-supergraph ./supergraph.yaml
This will add the new subgraph to your supergraph.yaml:
kind: Supergraph
version: v2
definition:
subgraphs:
- globals/subgraph.yaml
- app/subgraph.yaml
- <subgraph-name>/subgraph.yaml