Configure WunderNode options

This section describes how to set configurations options of WunderNode.

List of available options:

During development all options are optional and will be set via EnvironmentVariables with default values

listen.host (optional)

The host on which the WunderNode should listen.

listen.port (optional)

The port on which the WunderNode should listen.

nodeUrl (optional)

This option allows you to configure the internal URL where your WunderNode will be deployed in the internal network. This is important for the WunderGraph Server to be able to comminucate with WunderNode.

The nodeUrl is used in internal client requests to WunderNode in the hooks and webhooks.

publicNodeUrl (optional)

This option allows you to configure the Public URL on which you WunderNode Api will be accessible. It is used for example in the generated clients, in the GraphQL playground, OpenAPI specification and Postman collection.

logger.level (optional)

This option allows you to configure the logger level of WunderNode.

prometheus.enabled (optional)

This option indicates whether Prometheus metrics collection and exposure should be enabled.

prometheus.port (optional)

This option controls the port used to listen on for serving Prometheus metrics. The metrics are available at http://<host>:<prometheus.port>/metrics.

openTelemetry.enabled (optional)

This option indicates whether OpenTelemetry tracing should be enabled.

openTelemetry.sampler (optional)

This option defines the sampling rate of traces. Must be a value between 0 and 1. For example, a value of 0.1 means 10% of traces are sampled. Don't set this to 1 in production, unless you want to trace every request.

openTelemetry.exporterHttpEndpoint (optional)

This option allows you to configure the OpenTelemetry HTTP exporter endpoint. The default endpoint is http://localhost:4318. The current supported OTLP endpoint is set fixed to /v1/tracer.

openTelemetry.authToken (optional)

This option allows you to configure the OpenTelemetry HTTP exporter with an authentication token. Currently, we only support JWT authentication in combination with our JWT authenticator plugin.

Options default values

Each option when unset will get a value from the Default Environment Variables or from the default value of that variable.

OptionDefault ValueDefault Environment Variable
listen.hostlocalhostWG_NODE_HOST
listen.port9991WG_NODE_PORT
listenInternal.port9993WG_NODE_INTERNAL_PORT
nodeUrlhttp://localhost:9991WG_NODE_URL
publicNodeUrlhttp://localhost:9991WG_PUBLIC_NODE_URL
logger.levelinfoWG_LOG_LEVEL
prometheus.enabledfalseWG_PROMETHEUS_ENABLED
prometheus.port8881WG_PROMETHEUS_PORT
openTelemetry.enabledfalseWG_OTEL_ENABLED
openTelemetry.sampler1.0WG_OTEL_SAMPLER
openTelemetry.exporterHttpEndpointhttp://localhost:4318WG_OTEL_EXPORTER_HTTP_ENDPOINT
openTelemetry.authToken``WG_OTEL_AUTH_TOKEN

In case in options only listen.port is provided, the nodeUrl and publicNodeUrl will be set to http://localhost:<port>

Running in production

In production it is mandatory to provide:

  • publicNodeUrl - to have a proper configuration of generated clients, graphiql, graphqlconfig and postman collection
  • nodeUrl - when you want to run WunderNode in a different network/host than WunderGraph Server

You could provide it either by setting the Default Environment Variable or as a static value:

When no options were provided you still could override default values by setting WG environment variables

When using custom environment variables, you need to make sure that the environment variables are set before:

Configuration examples

Configure options with static values

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
configureWunderGraphApplication({
options: {
listen: {
host: 'localhost',
port: '4444',
},
listenInternal: {
port: '4445',
},
nodeUrl: 'http://my-internal-network-node:4444/',
publicNodeUrl: 'http://my-api.example.com/',
logger: {
level: 'DEBUG',
},
},
});

Configure options with custom environment variables

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { EnvironmentVariable, LoggerLevel } from '@wundergraph/sdk';
configureWunderGraphApplication({
options: {
listen: {
host: new EnvironmentVariable('NODE_HOST', 'localhost'),
port: new EnvironmentVariable('NODE_PORT', '4444'),
},
listenInternal: {
port: new EnvironmentVariable('NODE_INTERNAL_PORT', '4445'),
},
nodeUrl: new EnvironmentVariable('NODE_URL', 'http://localhost:4444/'),
publicNodeUrl: new EnvironmentVariable('PUBLIC_NODE_URL', 'http://my-api.example.com/'),
logger: {
level: new EnvironmentVariable<LoggerLevel>('NODE_LOG_LEVEL', 'info'),
},
},
});

Configure options with default environment variables

This configuration illustrates what options you will get when options are not provided via the config.

By using default environment variables names you could stick with Wundergraph Default behaviour but supply different default values.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { EnvironmentVariable, LoggerLevel, WgEnv } from '@wundergraph/sdk';
// use WgEnv enum to set variable names
configureWunderGraphApplication({
options: {
listen: {
host: new EnvironmentVariable(WgEnv.NodeHost, 'localhost'),
port: new EnvironmentVariable(WgEnv.NodePort, '9991'),
},
listenInternal: {
port: new EnvironmentVariable(WgEnv.NodeInternalPort, '9993'),
},
nodeUrl: new EnvironmentVariable(WgEnv.NodeUrl, 'http://localhost:9991/'),
publicNodeUrl: new EnvironmentVariable(WgEnv.PublicNodeUrl, 'http://my-api.example.com/'),
logger: {
level: new EnvironmentVariable<LoggerLevel>(WgEnv.LogLevel, 'info'),
},
},
});
// alternative using plain string variable names
configureWunderGraphApplication({
options: {
listen: {
host: new EnvironmentVariable('WG_NODE_HOST', 'localhost'),
port: new EnvironmentVariable('WG_NODE_PORT', '9991'),
},
listenInternal: {
port: new EnvironmentVariable('WG_NODE_INTERNAL_PORT', '9993'),
},
nodeUrl: new EnvironmentVariable('WG_NODE_URL', 'http://localhost:9991/'),
publicNodeUrl: new EnvironmentVariable('WG_PUBLIC_NODE_URL', 'http://my-api.example.com/'),
logger: {
level: new EnvironmentVariable<LoggerLevel>('WG_LOG_LEVEL', 'info'),
},
},
});

Was this article helpful to you?
Provide feedback

Edit this page