Skip to main content
Version: v3.x

Build configs

Introduction

Build configs are used to define the resources and other configurations required to build a supergraph, subgraph or a connector. They are written in YAML and are defined in individual files.

It's helpful to think of build configs as a blueprint for building your supergraph. The following options are available to you:

Config typeDescription
SupergraphDefines the configuration used to build a supergraph.
SubgraphDefines the configuration used to build a subgraph.
ConnectorDefines the configuration used to build a connector.

How the Supergraph config works

Lifecycle

The Supergraph object defines the configuration used to build the supergraph. While projects are generated with default configs for building for local or Hasura DDN when initializing a new supergraph, you can add as many Supergraph objects as you need to define different configurations for building your supergraph.

You can then use these files to build your supergraph — either locally or on Hasura DDN — using the CLI. These builds — when on Hasura DDN — can then be applied to a project which will then serve the API using the supergraph built from the configuration.

Examples

A supergraph.yaml config file:
kind: Supergraph
version: v2
definition:
subgraphs:
- globals/subgraph.yaml
- app/subgraph.yaml
FieldDescriptionReference
kindSpecifies the type of configuration, in this case, Supergraph.Supergraph
versionThe version of the Supergraph configuration, which is v2.Supergraph
definition.subgraphsPaths to the subgraph configuration files that are included in the supergraph build.SupergraphDefinitionV2

How the Subgraph config works

Lifecycle

Each subgraph in your supergraph has its own config. The Subgraph object defines the configuration used to build the subgraph. While subgraphs are generated with a default config when initializing a new subgraph, you can add as many Subgraph objects as you need to define different configurations for building a subgraph.

You can then use these files to build a subgraph using the CLI. These subgraph builds can then be applied to a project.

Examples

A supergraph.yaml config file:
kind: Subgraph
version: v2
definition:
name: app
generator:
rootPath: .
includePaths:
- metadata
envMapping:
APP_MY_CONNECTOR_AUTHORIZATION_HEADER:
fromEnv: APP_MY_CONNECTOR_AUTHORIZATION_HEADER
APP_MY_CONNECTOR_READ_URL:
fromEnv: APP_MY_CONNECTOR_READ_URL
APP_MY_CONNECTOR_WRITE_URL:
fromEnv: APP_MY_CONNECTOR_WRITE_URL
connectors:
- path: connector/my_connector/connector.yaml
connectorLinkName: my_connector
FieldDescriptionReference
kindSpecifies the type of configuration, in this case, Subgraph.Subgraph
versionThe version of the Subgraph configuration, which is v2.Subgraph
definition.nameThe name of the subgraph.SubgraphDefinitionV2
definition.generator.rootPathPath to the directory containing all the subgraph metadata, in this case the current directory.SubgraphGeneratorConfig
definition.includePathsPaths to be included to construct the subgraph metadata.SubgraphDefinitionV2
definition.envMappingEnvironment variable mapping configuration. Typically, these will correspond to connector envs. Additionally, when you initialize a connector, the CLI will automatically add the required envs to the subgraph.EnvMapping
definition.connectors.pathPath to the connector configuration file used in the subgraph.SubgraphConnector
definition.connectors.connectorLinkNameName of the connector link associated with the connector.SubgraphConnector

How the Connector config works

Lifecycle

Each data connector in your supergraph has its own config. The Connector object defines the configuration used to build the connector. This allows you to configure the capabilities of the connector and tailor it to your needs. While connectors are initialized with default configs for building for local or Hasura DDN, you can add as many Connector objects as you need to define different configurations for building your connector.

When you initialize a connector, the CLI will automatically create a connector config file for you. You can then use this file to build your connector using the CLI.

Examples

A connector.yaml config file:
kind: Connector
version: v2
definition:
name: MY_CONNECTOR
subgraph: app
source: hasura/postgres:v1.1.1
context: .
envMapping:
CONNECTION_URI:
fromEnv: APP_MY_CONNECTOR_CONNECTION_URI
HASURA_SERVICE_TOKEN_SECRET:
fromEnv: APP_MY_CONNECTOR_HASURA_SERVICE_TOKEN_SECRET
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:
fromEnv: APP_MY_CONNECTOR_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
OTEL_SERVICE_NAME:
fromEnv: APP_MY_CONNECTOR_OTEL_SERVICE_NAME
FieldDescriptionReference
kindSpecifies the type of configuration, in this case, Connector.Connector
versionThe version of the Connector configuration, which is v2.Connector
definition.nameThe name of the connector.ConnectorDefinitionV2
definition.subgraphThe name of the DDN project subgraph associated with the connector.ConnectorDefinitionV2
definition.sourceThe versioned source of the connector.ConnectorDefinitionV2
definition.contextThe path to the context directory used in the connector build.ConnectorDefinitionV2
definition.envMappingEnvironment variable mapping configuration for the connector.EnvMapping

Metadata structure

Supergraph

Defines the configuration used to build the Supergraph.

KeyValueRequiredDescription
kindSupergraphtrue
versionv2true
definitionSupergraphDefinitionV2true

SupergraphDefinitionV2

Supergraph Definition V2.

KeyValueRequiredDescription
subgraphs[string]truePaths to subgraph configuration.

Subgraph

Defines the configuration used to build the Subgraph.

KeyValueRequiredDescription
kindSubgraphtrue
versionv2true
definitionSubgraphDefinitionV2true

SubgraphDefinitionV2

Subgraph Definition V2.

KeyValueRequiredDescription
namestringtrueSubgraph Name.
generatorSubgraphGeneratorConfigtrueSubgraph generator Configuration.
envFilestringfalsePath to the Subgraph .env file.
includePaths[string]truePaths to be included to construct Subgraph metadata.
envMappingEnvMappingfalseEnvironment Variable mapping config.
connectors[SubgraphConnector]falseConnectors used in subgraph.

SubgraphConnector

Subgraph Connector config.

KeyValueRequiredDescription
pathstringtruePath to connector config file.
connectorLinkNamestringfalseName of connector link associated with the connector.

EnvMapping

Environment Variables mapping config.

KeyValueRequiredDescription
<customKey>EnvSourcefalseTarget Environment variable.

EnvSource

Environment Variable Source.

KeyValueRequiredDescription
fromEnvstringtrueSource Environment variable.

SubgraphGeneratorConfig

Subgraph generator Configuration.

KeyValueRequiredDescription
rootPathstringtruePath to the directory which holds all the Subgraph metadata.
graphqlRootFieldPrefixstringfalsePrefix to use while generating GraphQL root fields.
graphqlTypeNamePrefixstringfalsePrefix to use while generating GraphQL type names.
namingConventionnone / graphqlfalseNaming convention to use while generating GraphQL fields and types.

Connector

Defines the configuration used to build the connector.

KeyValueRequiredDescription
kindConnectortrue
versionv2true
definitionConnectorDefinitionV2true

ConnectorDefinitionV2

Connector deployment definition V2.

KeyValueRequiredDescription
namestringtrueConnector name.
subgraphstringfalseDDN project subgraph name.
sourcestringtrueConnector Hub ID.
contextstringtruePath to the context directory.
envFilestringfalsePath to the shared .env file.
envMappingEnvMappingfalseEnvironment Variable mapping config.
regionConfiguration[RegionConfigurationV2]falseConnector deployment Region configuration

RegionConfigurationV2

Connector deployment Region Configuration V2.

KeyValueRequiredDescription
regionstringtrueRegion to deploy the connector to.
modeReadOnly / ReadWritetrueConnector deployment mode.
envMappingEnvMappingfalseEnvironment Variable mapping config.

EnvMapping

Environment Variables mapping config.

KeyValueRequiredDescription
<customKey>EnvSourcefalseTarget Environment variable.

EnvSource

Environment Variable Source.

KeyValueRequiredDescription
fromEnvstringtrueSource Environment variable.
Loading...