wundergraph.config.ts Reference

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.

The publicNodeUrl is used to set a base URL for the .graphqlconfig file, postman collection and generated clients.

logger.level (optional)

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

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
nodeUrlhttp://localhost:9991WG_NODE_URL
publicNodeUrlhttp://localhost:9991WG_PUBLIC_NODE_URL
logger.levelinfoWG_LOG_LEVEL

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
configureWunderGraphApplication({
options: {
listen: {
host: 'localhost',
port: '4444',
},
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'),
},
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'),
},
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'),
},
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'),
},
},
})
Previous
Overview

Was this article helpful to you?
Provide feedback

Edit this page