You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds support for configurable subgraph request timeouts via the `traffic_shaping` configuration. The `request_timeout` option allows you to specify the maximum time the router will wait for a response from a subgraph before timing out the request. You can set a static timeout (e.g., `30s`) globally or per-subgraph, or use dynamic timeouts with VRL expressions to vary timeout values based on request characteristics. This helps protect your router from hanging requests and enables fine-grained control over how long requests to different subgraphs should be allowed to run.
-**`#[serde(...)]`** enables human-readable time formats (e.g., `"30s"`, `"1m30s"`) in config files.
105
+
-**`#[schemars(with = "String")]`** ensures the JSON schema correctly represents the field as a string, not as a numeric value.
106
+
107
+
**Important:** This pattern applies **only** to the `router-config` crate.
108
+
109
+
---
110
+
84
111
## Releasing
85
112
86
113
We are using `knope` with changesets for declaring changes. If you detect a new file in a PR under `.changeset/` directory, please confirm the following rules:
|[**supergraph**](#supergraph)|`object`|Configuration for the Federation supergraph source. By default, the router will use a local file-based supergraph source (`./supergraph.graphql`).<br/>||
19
-
|[**traffic\_shaping**](#traffic_shaping)|`object`|Configuration for the traffic-shaping of the executor. Use these configurations to control how requests are being executed to subgraphs.<br/>Default: `{"dedupe_enabled":true,"max_connections_per_host":100,"pool_idle_timeout":"50s"}`<br/>||
19
+
|[**traffic\_shaping**](#traffic_shaping)|`object`|Configuration for the traffic-shaping of the executor. Use these configurations to control how requests are being executed to subgraphs.<br/>Default: `{"all":{"dedupe_enabled":true,"pool_idle_timeout":"50s","request_timeout":"30s"},"max_connections_per_host":100}`<br/>||
20
20
21
21
**Additional Properties:** not allowed
22
22
**Example**
@@ -113,9 +113,11 @@ query_planner:
113
113
timeout: 10s
114
114
supergraph: {}
115
115
traffic_shaping:
116
-
dedupe_enabled: true
116
+
all:
117
+
dedupe_enabled: true
118
+
pool_idle_timeout: 50s
119
+
request_timeout: 30s
117
120
max_connections_per_host: 100
118
-
pool_idle_timeout: 50s
119
121
120
122
```
121
123
@@ -1744,7 +1746,7 @@ The path can be either absolute or relative to the router's working directory.
1744
1746
|Name|Type|Description|Required|
1745
1747
|----|----|-----------|--------|
1746
1748
|**path**|`string`|The path to the supergraph file.<br/><br/>Can also be set using the `SUPERGRAPH_FILE_PATH` environment variable.<br/>Format: `"path"`<br/>|yes|
1747
-
|[**poll\_interval**](#option1poll_interval)|`object`, `null`|Optional interval at which the file should be polled for changes.<br/>|yes|
1749
+
|**poll\_interval**|`string`|Optional interval at which the file should be polled for changes.<br/>If not provided, the file will only be loaded once when the router starts.<br/>|no|
@@ -1766,11 +1768,11 @@ Loads a supergraph from Hive Console CDN.
1766
1768
|Name|Type|Description|Required|
1767
1769
|----|----|-----------|--------|
1768
1770
|**accept\_invalid\_certs**|`boolean`|Whether to accept invalid TLS certificates when connecting to the Hive Console CDN.<br/>Default: `false`<br/>|no|
1769
-
|[**connect\_timeout**](#option2connect_timeout)|`object`|Connect timeout for the Hive Console CDN requests.<br/>Default: `"10s"`<br/>|yes|
1771
+
|**connect\_timeout**|`string`|Connect timeout for the Hive Console CDN requests.<br/>Default: `"10s"`<br/>|no|
1770
1772
|**endpoint**|`string`|The CDN endpoint from Hive Console target.<br/><br/>Can also be set using the `HIVE_CDN_ENDPOINT` environment variable.<br/>|yes|
1771
1773
|**key**|`string`|The CDN Access Token with from the Hive Console target.<br/><br/>Can also be set using the `HIVE_CDN_KEY` environment variable.<br/>|yes|
1772
-
|[**poll\_interval**](#option2poll_interval)|`object`|Interval at which the Hive Console should be polled for changes.<br/>Default: `"10s"`<br/>|yes|
1773
-
|[**request\_timeout**](#option2request_timeout)|`object`|Request timeout for the Hive Console CDN requests.<br/>Default: `"1m"`<br/>|yes|
1774
+
|**poll\_interval**|`string`|Interval at which the Hive Console should be polled for changes.<br/><br/>Can also be set using the `HIVE_CDN_POLL_INTERVAL` environment variable.<br/>Default: `"10s"`<br/>|no|
1775
+
|**request\_timeout**|`string`|Request timeout for the Hive Console CDN requests.<br/>Default: `"1m"`<br/>|no|
1774
1776
|[**retry\_policy**](#option2retry_policy)|`object`|Interval at which the Hive Console should be polled for changes.<br/>Default: `{"max_retries":10}`<br/>|yes|
|**max\_retries**|`integer`|The maximum number of retries to attempt.<br/><br/>Retry mechanism is based on exponential backoff, see https://docs.rs/retry-policies/latest/retry_policies/policies/struct.ExponentialBackoff.html for additional details.<br/>Format: `"uint32"`<br/>Minimum: `0`<br/>|yes|
1824
1806
1825
1807
**Example**
1826
1808
1827
1809
```yaml
1828
-
10s
1810
+
max_retries: 10
1829
1811
1830
1812
```
1831
1813
1832
-
<a name="option2poll_interval"></a>
1833
-
## Option 2: poll\_interval: object
1834
-
1835
-
Interval at which the Hive Console should be polled for changes.
1814
+
<a name="traffic_shaping"></a>
1815
+
## traffic\_shaping: object
1836
1816
1837
-
Can also be set using the `HIVE_CDN_POLL_INTERVAL` environment variable.
1817
+
Configuration for the traffic-shaping of the executor. Use these configurations to control how requests are being executed to subgraphs.
|[**all**](#traffic_shapingall)|`object`|The default configuration that will be applied to all subgraphs, unless overridden by a specific subgraph configuration.<br/>Default: `{"dedupe_enabled":true,"pool_idle_timeout":"50s","request_timeout":"30s"}`<br/>||
1825
+
|**max\_connections\_per\_host**|`integer`|Limits the concurrent amount of requests/connections per host/subgraph.<br/>Default: `100`<br/>Format: `"uint"`<br/>Minimum: `0`<br/>||
1826
+
|[**subgraphs**](#traffic_shapingsubgraphs)|`object`|Optional per-subgraph configurations that will override the default configuration for specific subgraphs.<br/>||
1846
1827
1828
+
**Additional Properties:** not allowed
1847
1829
**Example**
1848
1830
1849
1831
```yaml
1850
-
10s
1832
+
all:
1833
+
dedupe_enabled: true
1834
+
pool_idle_timeout: 50s
1835
+
request_timeout: 30s
1836
+
max_connections_per_host: 100
1851
1837
1852
1838
```
1853
1839
1854
-
<a name="option2request_timeout"></a>
1855
-
## Option 2: request\_timeout: object
1840
+
<a name="traffic_shapingall"></a>
1841
+
### traffic\_shaping\.all: object
1856
1842
1857
-
Request timeout for the Hive Console CDN requests.
1843
+
The default configuration that will be applied to all subgraphs, unless overridden by a specific subgraph configuration.
|**dedupe\_enabled**|`boolean`|Enables/disables request deduplication to subgraphs.<br/><br/>When requests exactly matches the hashing mechanism (e.g., subgraph name, URL, headers, query, variables), and are executed at the same time, they will<br/>be deduplicated by sharing the response of other in-flight requests.<br/>Default: `true`<br/>||
1851
+
|**pool\_idle\_timeout**|`string`|Timeout for idle sockets being kept-alive.<br/>Default: `"50s"`<br/>||
1852
+
|**request\_timeout**||Optional timeout configuration for requests to subgraphs.<br/><br/>Example with a fixed duration:<br/>```yaml<br/> timeout:<br/> duration: 5s<br/>```<br/><br/>Or with a VRL expression that can return a duration based on the operation kind:<br/>```yaml<br/> timeout:<br/> expression: \|<br/> if (.request.operation.type == "mutation") {<br/> "10s"<br/> } else {<br/> "15s"<br/> }<br/>```<br/>Default: `"30s"`<br/>||
1866
1853
1854
+
**Additional Properties:** not allowed
1867
1855
**Example**
1868
1856
1869
1857
```yaml
1870
-
1m
1858
+
dedupe_enabled: true
1859
+
pool_idle_timeout: 50s
1860
+
request_timeout: 30s
1871
1861
1872
1862
```
1873
1863
1874
-
<a name="option2retry_policy"></a>
1875
-
## Option 2: retry\_policy: object
1864
+
<a name="traffic_shapingsubgraphs"></a>
1865
+
### traffic\_shaping\.subgraphs: object
1876
1866
1877
-
Interval at which the Hive Console should be polled for changes.
1878
-
1879
-
By default, an exponential backoff retry policy is used, with 10 attempts.
1867
+
Optional per-subgraph configurations that will override the default configuration for specific subgraphs.
1880
1868
1881
1869
1882
-
**Properties**
1870
+
**Additional Properties**
1883
1871
1884
1872
|Name|Type|Description|Required|
1885
1873
|----|----|-----------|--------|
1886
-
|**max\_retries**|`integer`|The maximum number of retries to attempt.<br/><br/>Retry mechanism is based on exponential backoff, see https://docs.rs/retry-policies/latest/retry_policies/policies/struct.ExponentialBackoff.html for additional details.<br/>Format: `"uint32"`<br/>Minimum: `0`<br/>|yes|
1887
-
1888
-
**Example**
1889
-
1890
-
```yaml
1891
-
max_retries: 10
1892
-
1893
-
```
1894
-
1895
-
<a name="traffic_shaping"></a>
1896
-
## traffic\_shaping: object
1897
-
1898
-
Configuration for the traffic-shaping of the executor. Use these configurations to control how requests are being executed to subgraphs.
|**dedupe\_enabled**|`boolean`|Enables/disables request deduplication to subgraphs.<br/><br/>When requests exactly matches the hashing mechanism (e.g., subgraph name, URL, headers, query, variables), and are executed at the same time, they will<br/>be deduplicated by sharing the response of other in-flight requests.<br/>Default: `true`<br/>||
1906
-
|**max\_connections\_per\_host**|`integer`|Limits the concurrent amount of requests/connections per host/subgraph.<br/>Default: `100`<br/>Format: `"uint"`<br/>Minimum: `0`<br/>||
1907
-
|**pool\_idle\_timeout**|`string`|Timeout for idle sockets being kept-alive.<br/>Default: `"50s"`<br/>||
1883
+
|**dedupe\_enabled**|`boolean`, `null`|Enables/disables request deduplication to subgraphs.<br/><br/>When requests exactly matches the hashing mechanism (e.g., subgraph name, URL, headers, query, variables), and are executed at the same time, they will<br/>be deduplicated by sharing the response of other in-flight requests.<br/>||
1884
+
|**pool\_idle\_timeout**|`string`, `null`|Timeout for idle sockets being kept-alive.<br/>||
1885
+
|**request\_timeout**||Optional timeout configuration for requests to subgraphs.<br/><br/>Example with a fixed duration:<br/>```yaml<br/> timeout:<br/> duration: 5s<br/>```<br/><br/>Or with a VRL expression that can return a duration based on the operation kind:<br/>```yaml<br/> timeout:<br/> expression: \|<br/> if (.request.operation.type == "mutation") {<br/> "10s"<br/> } else {<br/> "15s"<br/> }<br/>```<br/>||
0 commit comments