@upstream Directive

The @upstream directive controls how GQLForge connects to backend services. It governs connection pooling, timeouts, TLS, and request batching.

Fields

FieldTypeDefaultDescription
on_requestStringnullName of a JS function invoked before every upstream request.
allowed_headers[String][]Client request headers forwarded to upstream services.
batchBatchnullConfiguration for HTTP request batching. See below.
connect_timeoutInt60Maximum time in seconds to establish a TCP connection.
http_cacheIntnullMaximum number of entries in the HTTP response cache.
http2_onlyBooleanfalseForce HTTP/2 for all upstream connections.
keep_alive_intervalInt60Interval in seconds between TCP keep-alive probes.
keep_alive_timeoutInt60Time in seconds to wait for a keep-alive response.
keep_alive_while_idleBooleanfalseSend keep-alive probes even when the connection is idle.
pool_max_idle_per_hostInt60Maximum idle connections retained per upstream host.
pool_idle_timeoutInt60Time in seconds before an idle connection is closed.
proxyProxynullHTTP proxy configuration. See below.
tcp_keep_aliveInt5Interval in seconds for OS-level TCP keep-alive.
timeoutInt60Total request timeout in seconds.
user_agentString"GQLForge"Value of the User-Agent header sent to upstreams.
verify_sslBooleantrueVerify TLS certificates for upstream connections.

Batch Configuration

FieldTypeDefaultDescription
delayInt0Time in milliseconds to wait before dispatching a batch.
headers[String][]Headers included when grouping requests into batches.
max_sizeInt100Maximum number of requests in a single batch.

Proxy Configuration

FieldTypeDescription
urlStringThe proxy server URL (e.g. http://proxy:8080).

Example

schema
@upstream(
  connect_timeout: 10
  timeout: 30
  http_cache: 1000
  http2_only: false
  verify_ssl: true
  batch: { delay: 10, max_size: 50 }
  allowed_headers: ["Authorization", "X-Request-Id"]
) {
  query: Query
}