Remove a subgraph
Introduction
In this recipe, you'll learn how to remove a subgraph from your local project directory.
Before continuing, ensure you have:
- A local Hasura DDN project.
- Stopped any running docker services related to the project.
Recipe
Step 1. Delete subgraph directory
Delete the directory containing the subgraph related config files, connectors and metadata of the subgraph. The subgraph
directory is typically located at <subgraph-name>
.
Step 2. Update supergraph config files
Remove the path to the subgraph config files in all
supergraph config files. The supergraph config file is typically
located at the project root, i.e., <project-root>/supergraph.yaml
.
kind: Supergraph
version: v2
definition:
subgraphs:
- globals/subgraph.yaml
- <subgraph-name>/subgraph.yaml
...
Step 3. Update engine compose file
Remove references to any compose files of connectors in the deleted subgraph from the engine compose file. The engine
compose file is typically located at <project-root>/compose.yaml
.
include:
- path: <subgraph-name>/connector/<connector-1>/compose.yaml
- path: <subgraph-name>/connector/<connector-2>/compose.yaml
...
services:
engine: ...
Step 4. Remove subgraph config file from context
The context config file located at .hasura/context.yaml
may have the
subgraph config file path saved in the context. Remove the subgraph
key if set as the deleted subgraph config file.
kind: Context
version: v3
definition:
current: default
contexts:
default:
supergraph: ../supergraph.yaml
subgraph: ../<subgraph-name>/subgraph.yaml
...
Step 5. (Optional) Remove subgraph relevant environment variables
You can remove the environment variables that were defined for your subgraph from the env files that you might have. The
CLI-generated environment variables for a subgraph typically start with the <SUBGRAPH_NAME>_
prefix.
...
<SUBGRAPH_NAME>_<CONNECTOR>_READ_URL="<connector-read-url>"
<SUBGRAPH_NAME>_<CONNECTOR>_WRITE_URL="<connector-write-url>"
<SUBGRAPH_NAME>_<CONNECTOR>_AUTHORIZATION_HEADER="Bearer <roken>"
...