Configure multiple Grafts
When to use this
One application consumes several Grafts — some in-memory, some remote — without a monolithic config file.
Deep reference: Runtime call execution.
Prerequisites
- GraftConfig reference
- Multiple Grafts installed
Rules
- Each Graft resolves independently
- Per-Graft config always overrides global config
- Precedence within same Graft name: env > file > code > default
- Global config has no Graft name — it defines shared baseline (e.g. default remote host)

Global configuration
Applies to all Grafts unless overridden.
File: graftcode-config.json
{ "host": "tcp://shared-gateway:8990" }
All Grafts call through shared-gateway unless they define their own config.
Per-Graft configuration
Use the Graft's exact package name as the config entry name.
File: @graft-nuget-Orders-config.json
{ "host": "tcp://order-service:8990" }
File: @graft-nuget-Catalog-config.json
{ "host": "tcp://catalog-service:8990" }
Or in code:
import { GraftConfig as OrdersConfig } from "@graft/nuget-Orders"; import { GraftConfig as CatalogConfig } from "@graft/nuget-Catalog"; OrdersConfig.host = "tcp://orders:8990"; CatalogConfig.host = "tcp://catalog:8990";
Mixed execution example
| Graft | Config | Execution |
|---|---|---|
@graft/nuget-SharedLib | (none) | In-memory (monolith module) |
@graft/nuget-Billing | tcp://billing:8990 | Remote microservice |
@graft/nuget-Legacy | tcp://legacy:8990 | Remote legacy host |
// SharedLib: no host → in-memory import { Helper } from "@graft/nuget-SharedLib"; // Billing: per-graft config file sets tcp://billing:8990 import { BillingService } from "@graft/nuget-Billing";
Environment variables
Runtime-specific and global env vars beat config files. Use in CI/CD for production hosts without rebuilding.
See Environment variables and Config file formats.
Verify it works
- In-memory Graft works with remote GG stopped (for that module)
- Remote Grafts fail when their target GG is down
- Changing one Graft's config does not affect others
Common mistakes
| Mistake | Fix |
|---|---|
| Global host forces all remote | Add per-Graft override files |
| Wrong config file name | Match exact graft package name |
Expecting one host for all | Use per-Graft files or separate GraftConfig imports |