Skip to content

Commit 114b22f

Browse files
committed
fix CI and README
1 parent c444477 commit 114b22f

File tree

15 files changed

+119
-26
lines changed

15 files changed

+119
-26
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ jobs:
218218
echo "Docker image: ${{ env.DOCKER_IMAGE_NAME }}@${{ needs.docker.outputs.docker_image_digest }}"
219219
220220
docker run -d --name router -p 4000:4000 \
221-
-e HIVE__SUPERGRAPH__SOURCE="file" \
222-
-e HIVE__SUPERGRAPH__PATH="/app/supergraph.graphql" \
221+
-e SUPERGRAPH_FILE_PATH="/app/supergraph.graphql" \
223222
-v ./bench/supergraph.graphql:/app/supergraph.graphql \
224223
${{ env.DOCKER_IMAGE_NAME }}@${{ needs.docker.outputs.docker_image_digest }}
225224

.github/workflows/ci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ jobs:
130130
- name: Run router
131131
run: ./target/release/hive_router & sleep 5
132132
env:
133-
HIVE__SUPERGRAPH__SOURCE: file
134-
HIVE__SUPERGRAPH__PATH: bench/supergraph.graphql
133+
SUPERGRAPH_FILE_PATH: bench/supergraph.graphql
135134
- name: Run k6 benchmark
136135
run: k6 run bench/k6.js
137136

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ supergraph:
3535
Alternativly, you can use environment variables to configure the router:
3636
3737
```env
38-
HIVE__SUPERGRAPH__SOURCE=file
39-
HIVE__SUPERGRAPH__PATH=./supergraph.graphql
38+
SUPERGRAPH_FILE_PATH=./supergraph.graphql
4039
```
4140

4241
Then, run the router:
@@ -58,8 +57,7 @@ The router image is being published to [Docker to GitHub Container Registry]().
5857
```bash
5958
docker run \
6059
-p 4000:4000 \
61-
-e HIVE__SUPERGRAPH__SOURCE="file" \
62-
-e HIVE__SUPERGRAPH__PATH="/app/supergraph.graphql" \
60+
-e SUPERGRAPH_FILE_PATH="/app/supergraph.graphql" \
6361
-v ./my-supergraph.graphql:/app/supergraph.graphql \
6462
ghcr.io/graphql-hive/router:latest
6563
```

audits/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"test:federation-all": "graphql-federation-audit test --run-script=\"./run-router.sh\" --graphql=\"http://localhost:4000/graphql\" --healthcheck=\"http://localhost:4000/health\" --junit",
77
"test:federation-single": "graphql-federation-audit test-suite --run-script=\"./run-router.sh\" --graphql=\"http://localhost:4000/graphql\" --healthcheck=\"http://localhost:4000/health\" --write=\"federation-audit-results.txt\"",
8-
"start:test-router": "cd .. && HIVE__SUPERGRAPH__SOURCE=file HIVE__SUPERGRAPH__PATH=lib/query-planner/fixture/spotify-supergraph.graphql cargo router",
8+
"start:test-router": "cd .. && SUPERGRAPH_FILE_PATH=lib/query-planner/fixture/spotify-supergraph.graphql cargo router",
99
"test:graphql-over-http": "node --test graphql-over-http.test.js",
1010
"test-junit:graphql-over-http": "node --test --test-reporter=junit --test-reporter-destination=\"./reports/graphql-over-http.xml\" graphql-over-http.test.js",
1111
"ci:test:graphql-over-http": "start-server-and-test start:test-router http://localhost:4000 test-junit:graphql-over-http"

audits/run-router.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ echo "running router..."
1111

1212
cd ..
1313

14-
export HIVE__SUPERGRAPH__SOURCE="file"
15-
export HIVE__SUPERGRAPH__PATH="audits/fed-audit-supergraph.graphql"
14+
export SUPERGRAPH_FILE_PATH="audits/fed-audit-supergraph.graphql"
1615
cargo router

bench/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
```
44
cargo subgraphs
55
6-
export HIVE__SUPERGRAPH__SOURCE="file"
7-
export HIVE__SUPERGRAPH__PATH="bench/supergraph.graphql"
6+
export SUPERGRAPH_FILE_PATH="bench/supergraph.graphql"
87
cargo router
98
```
109

bin/router/src/pipeline/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ pub async fn graphql_request_handler(
5353
schema_state: &Arc<SchemaState>,
5454
) -> web::HttpResponse {
5555
if req.method() == Method::GET && req.accepts_content_type(*TEXT_HTML_CONTENT_TYPE) {
56-
return web::HttpResponse::Ok()
57-
.header(CONTENT_TYPE, *TEXT_HTML_CONTENT_TYPE)
58-
.body(GRAPHIQL_HTML);
56+
if shared_state.router_config.graphiql.enabled {
57+
return web::HttpResponse::Ok()
58+
.header(CONTENT_TYPE, *TEXT_HTML_CONTENT_TYPE)
59+
.body(GRAPHIQL_HTML);
60+
} else {
61+
return web::HttpResponse::NotFound().into();
62+
}
5963
}
6064

6165
if let Some(jwt) = &shared_state.jwt_auth_runtime {

docker/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ Use the following command to run the Docker image locally:
3737

3838
```bash
3939
docker run -p 4000:4000 \
40-
-e HIVE__SUPERGRAPH__SOURCE="file" \
41-
-e HIVE__SUPERGRAPH__PATH="/app/supergraph.graphql" \
40+
-e SUPERGRAPH_FILE_PATH="/app/supergraph.graphql" \
4241
-v ./bench/supergraph.graphql:/app/supergraph.graphql \
4342
<ID_OF_THE_LOCAL_IMAGE>
4443
```

docs/README.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
|----|----|-----------|--------|
77
|[**cors**](#cors)|`object`|Configuration for CORS (Cross-Origin Resource Sharing).<br/>Default: `{"allow_any_origin":false,"allow_credentials":false,"enabled":false,"policies":[]}`<br/>|yes|
88
|[**csrf**](#csrf)|`object`|Configuration for CSRF prevention.<br/>Default: `{"enabled":false,"required_headers":[]}`<br/>||
9+
|[**graphiql**](#graphiql)|`object`|Configuration for the GraphiQL interface.<br/>Default: `{"enabled":true}`<br/>||
910
|[**headers**](#headers)|`object`|Configuration for the headers.<br/>Default: `{}`<br/>||
1011
|[**http**](#http)|`object`|Configuration for the HTTP server/listener.<br/>Default: `{"host":"0.0.0.0","port":4000}`<br/>||
1112
|[**jwt**](#jwt)|`object`, `null`|Configuration for JWT authentication plugin.<br/>|yes|
@@ -36,6 +37,8 @@ csrf:
3637
enabled: true
3738
required_headers:
3839
- x-csrf-token
40+
graphiql:
41+
enabled: true
3942
headers:
4043
all:
4144
request:
@@ -328,6 +331,26 @@ A valid HTTP header name, according to RFC 7230.
328331

329332
**Item Type:** `string`
330333
**Item Pattern:** `^[A-Za-z0-9!#$%&'*+\-.^_\`\|~]+$`
334+
<a name="graphiql"></a>
335+
## graphiql: object
336+
337+
Configuration for the GraphiQL interface.
338+
339+
340+
**Properties**
341+
342+
|Name|Type|Description|Required|
343+
|----|----|-----------|--------|
344+
|**enabled**|`boolean`|Enables/disables the GraphiQL interface. By default, the GraphiQL interface is enabled.<br/><br/>You can override this setting by setting the `GRAPHIQL_ENABLED` environment variable to `true` or `false`.<br/>Default: `true`<br/>||
345+
346+
**Additional Properties:** not allowed
347+
**Example**
348+
349+
```yaml
350+
enabled: true
351+
352+
```
353+
331354
<a name="headers"></a>
332355
## headers: object
333356

@@ -1304,8 +1327,8 @@ Configuration for the HTTP server/listener.
13041327

13051328
|Name|Type|Description|Required|
13061329
|----|----|-----------|--------|
1307-
|**host**|`string`|The host address to bind the HTTP server to.<br/>Default: `"0.0.0.0"`<br/>||
1308-
|**port**|`integer`|The port to bind the HTTP server to.<br/><br/>If you are running the router inside a Docker container, please ensure that the port is exposed correctly using `-p <host_port>:<container_port>` flag.<br/>Default: `4000`<br/>Format: `"uint16"`<br/>Minimum: `0`<br/>Maximum: `65535`<br/>||
1330+
|**host**|`string`|The host address to bind the HTTP server to.<br/><br/>Can also be set via the `HOST` environment variable.<br/>Default: `"0.0.0.0"`<br/>||
1331+
|**port**|`integer`|The port to bind the HTTP server to.<br/><br/>Can also be set via the `PORT` environment variable.<br/><br/>If you are running the router inside a Docker container, please ensure that the port is exposed correctly using `-p <host_port>:<container_port>` flag.<br/>Default: `4000`<br/>Format: `"uint16"`<br/>Minimum: `0`<br/>Maximum: `65535`<br/>||
13091332

13101333
**Additional Properties:** not allowed
13111334
**Example**
@@ -1499,9 +1522,9 @@ The router is configured to be mostly silent (`info`) level, and will print only
14991522

15001523
|Name|Type|Description|Required|
15011524
|----|----|-----------|--------|
1502-
|**filter**|`string`, `null`|||
1503-
|**format**|`string`|Default: `"json"`<br/>Enum: `"pretty-tree"`, `"pretty-compact"`, `"json"`<br/>||
1504-
|**level**|`string`|Default: `"info"`<br/>Enum: `"trace"`, `"debug"`, `"info"`, `"warn"`, `"error"`<br/>||
1525+
|**filter**|`string`, `null`|The filter to apply to log messages.<br/><br/>Can also be set via the `LOG_FILTER` environment variable.<br/>||
1526+
|**format**|`string`|The format of the log messages.<br/><br/>Can also be set via the `LOG_FORMAT` environment variable.<br/>Default: `"json"`<br/>Enum: `"pretty-tree"`, `"pretty-compact"`, `"json"`<br/>||
1527+
|**level**|`string`|The level of logging to use.<br/><br/>Can also be set via the `LOG_LEVEL` environment variable.<br/>Default: `"info"`<br/>Enum: `"trace"`, `"debug"`, `"info"`, `"warn"`, `"error"`<br/>||
15051528

15061529
**Additional Properties:** not allowed
15071530
**Example**
@@ -1593,7 +1616,7 @@ The path can be either absolute or relative to the router's working directory.
15931616

15941617
|Name|Type|Description|Required|
15951618
|----|----|-----------|--------|
1596-
|**path**|`string`|Format: `"path"`<br/>|yes|
1619+
|**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|
15971620
|[**poll\_interval**](#option1poll_interval)|`object`, `null`|Optional interval at which the file should be polled for changes.<br/>|yes|
15981621
|**source**|`string`|Constant Value: `"file"`<br/>|yes|
15991622

@@ -1615,8 +1638,8 @@ Loads a supergraph from Hive Console CDN.
16151638

16161639
|Name|Type|Description|Required|
16171640
|----|----|-----------|--------|
1618-
|**endpoint**|`string`|The CDN endpoint from Hive Console target.<br/>|yes|
1619-
|**key**|`string`|The CDN Access Token with from the Hive Console target.<br/>|yes|
1641+
|**endpoint**|`string`|The CDN endpoint from Hive Console target.<br/><br/>Can also be set using the `HIVE_CDN_ENDPOINT` environment variable.<br/>|yes|
1642+
|**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|
16201643
|[**poll\_interval**](#option2poll_interval)|`object`|Interval at which the Hive Console should be polled for changes.<br/>Default: `"10s"`<br/>|yes|
16211644
|[**retry\_policy**](#option2retry_policy)|`object`|Interval at which the Hive Console should be polled for changes.<br/>Default: `{"max_retries":10}`<br/>|yes|
16221645
|**source**|`string`|Constant Value: `"hive"`<br/>|yes|
@@ -1660,6 +1683,8 @@ If not provided, the file will only be loaded once when the router starts.
16601683

16611684
Interval at which the Hive Console should be polled for changes.
16621685

1686+
Can also be set using the `HIVE_CDN_POLL_INTERVAL` environment variable.
1687+
16631688

16641689
**Properties**
16651690

lib/router-config/src/env_overrides.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ pub struct EnvVarOverrides {
1414
#[envconfig(from = "LOG_FILTER")]
1515
pub log_filter: Option<String>,
1616

17+
// GraphiQL overrides
18+
#[envconfig(from = "GRAPHIQL_ENABLED")]
19+
pub graphiql_enabled: Option<bool>,
20+
1721
// HTTP overrides
1822
#[envconfig(from = "PORT")]
1923
pub http_port: Option<u64>,
@@ -27,6 +31,8 @@ pub struct EnvVarOverrides {
2731
pub hive_console_cdn_endpoint: Option<String>,
2832
#[envconfig(from = "HIVE_CDN_KEY")]
2933
pub hive_console_cdn_key: Option<String>,
34+
#[envconfig(from = "HIVE_CDN_POLL_INTERVAL")]
35+
pub hive_console_cdn_poll_interval: Option<String>,
3036
}
3137

3238
#[derive(Debug, thiserror::Error)]
@@ -85,6 +91,17 @@ impl EnvVarOverrides {
8591
} else {
8692
return Err(EnvVarOverridesError::MissingRequiredEnvVar("HIVE_CDN_KEY"));
8793
}
94+
95+
if let Some(hive_console_cdn_poll_interval) = self.hive_console_cdn_poll_interval.take()
96+
{
97+
config = config
98+
.set_override("supergraph.poll_interval", hive_console_cdn_poll_interval)?;
99+
}
100+
}
101+
102+
// GraphiQL overrides
103+
if let Some(graphiql_enabled) = self.graphiql_enabled.take() {
104+
config = config.set_override("graphiql.enabled", graphiql_enabled)?;
88105
}
89106

90107
Ok(config)

0 commit comments

Comments
 (0)