GraftConfig reference

When to use this

Every generated Graft exposes a GraftConfig class. Use it to set where and how calls execute.

Prerequisites


GraftConfig members

MemberPurpose
hostRemote Gateway address (tcp://, ws://, …). Unset = in-memory.
statelessHypertube session mode (true / false). Default false.
init()Initializes Hypertube runtime context (called automatically).
setConfig(...)Set connection string (partial support in Alpha).

Set host in code

TypeScript:

import { GraftConfig } from "@graft/nuget-EnergyPrice";

GraftConfig.host = "tcp://energy-service:8990";
// or WebSocket:
GraftConfig.host = "ws://localhost:8888/ws";

C#:

using graft.nuget.EnergyPrice;

GraftConfig.host = "tcp://energy-service:8990";

Leave host unset for in-memory execution in the same process as Hypertube.


Copy from Graftcode Vision

Vision's Configuration tab generates ready-to-paste snippets for your runtime:

Graftcode Vision Configuration tab showing a GraftConfig import and host assignment for WebSocket connectivity

Switch between In code, Config file, and ENV var in Vision to match how you configure each environment. See First run and Vision.


Stateless mode

GraftConfig.stateless = true;
GraftConfig.stateless = true;

Use with stateless interface design (static methods). See Stateless vs stateful execution.


Configuration without code

GraftConfig loads settings in precedence order (highest wins):

  1. Runtime-specific environment variable
  2. Global environment variable
  3. Runtime-specific config file
  4. Global config file
  5. Code (GraftConfig.setConfig / host)
  6. Graft package default
  7. Hypertube default (in-memory)

GraftConfig setting precedence — environment variables override files and code

Config file names

Global (all Grafts):

  • graftcode-config.json
  • graftcode-config.yaml
  • graftcode-config.txt

Per-Graft (replace with graft name):

  • {graft-name}-config.json
  • {graft-name}-config.yaml
  • {graft-name}-config.txt

Example graftcode-config.json:

{
  "host": "tcp://localhost:8990"
}

Full connection string format (Alpha: limited support):

name=@graft/nuget-EnergyPrice;runtime=netcore;host=ws://localhost:8888/ws

See Graft connection string.


Verify it works

  • Unset host → calls execute in-process
  • Set host → calls reach remote GG (check with Debugging runbook)

See also