Skip to main content

Gateway configuration options

Gateway Configuration File#

GraphQL Portal Gateway server is configured from gateway.json|yaml file which should be located in a directory ./config relative to the command.

For example, if we are launching graphql-portal command from /opt/graphql-portal directory, then the gateway configuration should be located in /opt/graphql-portal/config/gateway.json|yaml.

API Configuration Files#

It is possible to use the gateway with static configuration files, in that case you have to set use_dashboard_configs to false.

When done so, the gateway will try to load API Configurations from the directories specified in the following options:

  • apis_path
  • middleware_path
  • sources_path.

In all of the above options, the path is relative to the directory in which we launch the gateway, i.e. if we are launching the server in /opt/graphql-portal and the apis_path is set to config/apis, then we'll look for the files in /opt/graphql-portal/config/apis/ directory.

The combination of these options allows us to have a flexible configuration structure with separation of concerns, which if necessary can then be versioned. Here is an example of a typical configuration structure:

"use_dashboard_configs": false,
"apis_path": "config/apidefs",
"middleware_path": "config/middlewares",
"sources_path": "config/sources"

Our directory listing will then look like that:

$ tree config/
โ”œโ”€โ”€ apidefs
โ”‚ย ย  โ””โ”€โ”€ test-api.json
โ”œโ”€โ”€ datasources
โ”‚ย ย  โ””โ”€โ”€ test-data-source.yaml
โ”œโ”€โ”€ gateway.json
โ””โ”€โ”€ middlewares

Environment variables#

It is possible to override certain configuration options by using environment variables. To do that, you'll have to replace the values of the variables in the configuration file with @@ENV_VARIABLE_NAME.

For example, lets take the following configuration file:

"hostname": "@@HOSTNAME",
"listen_port": @@PORT,
"pool_size": 1,
"secret": "",
"apis_path": "config/apidefs",
"sources_path": "config/datasources",
"middleware_path": "config/middlewares",
"redis": {
"connection_string": "redis://localhost:6379"
"use_dashboard_configs": false,
"enable_control_api": false,
"log_level": "@@LOG_LEVEL"

As you can see, there are three values which were replaced with @@VARIABLE. Values which were specified in that way are going to be taken from the environment variables.


The hostname to bind the gateway node to.


The port on which GraphQL Portal Gateway will listen for the incoming connections.


Optional string. This value should be set to the external server name when gateway is used behind the load-balancer proxy.


Optional number. The size of the NodeJS Cluster pool, i.e. how many instances of the gateway are going to be launched on the same host. It is recommended to keep this number equal to the number of CPU cores on the machine. Setting this value to 1 will launch a single-instance gateway. Setting it to 0 or removing it will use all the available CPU cores on the machine.


This boolean value specifies whether to read the API configurations from the local file or from a GraphQL Portal Dashboard.

If set to false, the gateway will try to read the configuration files locally and will search for them in the locations specified in the following configuration options:

  • apis_path
  • middleware_path
  • sources_path.

If set to true, it will try to connect to dashboard (see below for dashboard configuration) and get the configuration from there.


Optional. This value will be used only when use_dashboard_configs is set to true.

It contains a required options connection_string, which specifies the URL and connection parameters to the Dashboard. Example:

"use_dashboard_configs": true,
"dashboard_config": {
"connection_string": "http://graphql-portal-dashboard.svc.local:8080"


Path to a directory with API definition files. Read more about API Configuration Files here.


Path to a directory with custom middlewares. API Configuration Files here


Path to a directory with data source files. API Configuration Files here


Enables or disables the Control API which is used to update GraphQL Schema definitions.


Optional. Used only when enable_control_api is set to true. Contains only one property endpoint which specifies the URL path on which to which the Control API will be bind.

"enable_control_api": true,
"control_api_config": {
"endpoint": "/control-api"


Optional. Enables and configures CORS requests. CORS requests from Dashboard are enabled by default when use_dashboard_configs is set to true.


Boolean, false by default. Enables CORS configuration.


Array of strings. Configures the Access-Control-Allow-Origin CORS header. Expects an Array of valid origins.


Array of strings. Configures the Access-Control-Allow-Methods CORS header. Expects an array of HTTP Methods.


Array of strings. Configures the Access-Control-Allow-Headers CORS header. Expects and Array of headers.


Array of strings. Configures the Access-Control-Expose-Headers CORS header.


Array of strings. Configures the Access-Control-Allow-Credentials CORS header.


Integer. Configures the Access-Control-Max-Age CORS header.


Integer. Provides a status code to use for successful OPTIONS requests, since some legacy browsers (IE11, various SmartTVs) choke on 204.


Boolean. Enables metrics gathering. Disabled by default.


Optional. Can be text or json. Default value is text.


Possible values are: 'debug' | 'info' | 'warn' | 'error'.


Configures sending of log messages to Datadog.


Boolean. Enable or disable logging to Datadog. Defaults to false.


String. Datadog API key of your application.


String. Host of the Datadog TCP (TLS) intake. Defaults to the US server (


Number. Port of the Datadog TCP (TLS) intake. Defaults to 10516.


String. Adds an environment attribute to Datadog logs. Empty by default.


Array of strings. Allows transport level tagging in Datadog. Each tag should follow the format <KEY>:<VALUE>. For more information see


Configures sending of log messages to Redis.


Boolean. Enable or disable logging to Redis. Defaults to false.


Number. Timeout in seconds, after the timeout has expired, the log will automatically be deleted, 30 by default.


Redis connection options.

Connection string specifying access to a Redis instance, for example:

"redis_connection_string": "redis://localhost:6379",

redis_connection_string is deprecated. Use redis.connection_string instead:

"redis": {
"connection_string": "redis://localhost:6379",

If you want to connect to a Redis cluster:

"redis": {
"is_cluster": true,
"cluster_nodes": ["redis://localhost:7001", "redis://localhost:7002", "redis://localhost:7003"],


Optional. Default value is 100kb. This value specifies an HTTP Request size limit. Accepts numeric (in bytes) or string values. When string is used, the following abbreviations are used:

  • b for bytes
  • kb for kilobytes
  • mb for megabytes
  • gb for gigabytes
  • tb for terabytes
  • pb for petabytes.


"request_size_limit": "20mb"


Optional. Configures tracing provides. Currently available providers:

  • Jaeger
  • Datadog


Boolean or name of provider in lowercase ("jaeger" or "datadog"). Enable or disable tracing. Defaults to false.


Optional. Configures sending of traces to Jaeger.


The host of your Jaeger agent. Defaults to "localhost".


The port of your Jaeger agent. Defaults to 6832.


Optional. Configures sending of traces to Datadog.


The host of your Datadog agent. Defaults to localhost.


The port of your Datadog agent. Defaults to 8126.


"tracing": {
"enable": "jaeger",
"jaeger": {
"host": "@@JAEGER_AGENT_HOST",
"port": "@@JAEGER_AGENT_PORT",