Skip to main content

Config

You can config the GBox via environment variables.

Environment variables​

Environment variableDescriptionDefault value
GBOX_GLOBAL_DIRECTIVESCaddy global options
GBOX_UPSTREAMYour GraphQL url
GBOX_UPSTREAM_REVERSE_PROXY_DIRECTIVESCaddy reverse proxy extra directives
GBOX_SERVER_NAMEServer name (host and port)localhost
GBOX_FETCH_SCHEMA_INTERVALInterval time to update SDL from upstream, set 0 to disabled this feature.10m
GBOX_ENABLED_COMPLEXITYWhether enabled filter query complexity or not.true
GBOX_NODE_COUNT_LIMITThe maximum number of Nodes a query may return. This option only affect when GBOX_ENABLED_COMPLEXITY set to "true".60
GBOX_MAX_COMPLEXITYThe maximum number of Node requests that might be needed to execute the query. This option only affect when GBOX_ENABLED_COMPLEXITY set to "true".60
GBOX_MAX_DEPTHThe maximum depth per node. This option only affect when GBOX_ENABLED_COMPLEXITY set to "true".15
GBOX_DISABLED_INTROSPECTIONWhether disabled introspection queries or not.false
GBOX_DISABLED_PLAYGROUNDSWhether disabled playgrounds or not.false
GBOX_ENABLED_CACHINGEnabled caching query results or nottrue
GBOX_STORE_DSNCaching store DSN, only support Redis or Freecache (memory cache).freecache://?cache_size=5368709120
GBOX_CACHING_RULESSet of caching rules to control cache behavior for every single query.
GBOX_CACHING_VARIESSet of caching varies headers and/or cookies to identifier cached query results.
GBOX_CACHING_TYPE_KEYSCaching type keys use to identifier query results items.If not specific key field for type, by default id will be use as key field for all types
GBOX_AUTO_INVALIDATE_CACHEWhether auto invalidate query results by mutation results through type keys or not.true
GBOX_CACHING_DEBUG_HEADERSWhether add cache debug headers to every responses like tags, cache key or not.true
GBOX_ENABLED_ADMIN_AUTHWhether enabled basic auth for admin endpoint.false
GBOX_ADMIN_USERNAMEAdmin basic auth username. This option only affect when GBOX_ENABLED_ADMIN_AUTH set to "true".gbox
GBOX_ADMIN_PASSWORDAdmin basic auth password. This option only affect when GBOX_ENABLED_ADMIN_AUTH set to "true".gbox
GBOX_ENABLED_METRICSWhether enabled Prometheus metrics endpoint.false
GBOX_METRICS_PATHMetrics endpoint. This option only affect when GBOX_ENABLED_METRICS set to "true"./metrics
GBOX_EXTRA_DIRECTIVESGBox extra directives

Caddy directives​

GBox is a custom build of the Caddy web server including the http.handlers.gbox module.

Read Caddy web server's getting started guide to learn the basics.

Global options​

You can add Caddy global options via GBOX_GLOBAL_DIRECTIVES environment variable.

Example:

GBOX_GLOBAL_DIRECTIVES: |
debug
admin off

GBox extra directives​

You can add more GBox directives via GBOX_EXTRA_DIRECTIVES environment variable, some useful directives below you may want to add.

DirectiveDescriptionExample
fetch_schema_headerHelp to add HTTP header when fetch schema through introspection queryfetch_schema_header header_name value
cors_originsA list of allowed CORS originscors_origins https://example1.org https://example2.org
cors_allowed_headersA list of allowed CORS HTTP headerscors_allowed_headers Authorization Cache-Control

Example:

GBOX_EXTRA_DIRECTIVES: |
cors_origins *
fetch_schema_header Authorization "Bearer xyz"
cors_allowed_headers Authorization Cache-Control
info

Header name is case-insensitive.

Use Redis as a caching store​

By default, the GBox will store cached data in memory, if you would like to store cached data in Redis, set the GBOX_STORE_DSN to your Redis DSN.

Example: redis://localhost:6379