Skip to content

Commit ce4d96a

Browse files
committed
Add prefix path option to graph-proxy
1 parent c2ee7b3 commit ce4d96a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

graph-proxy/src/main.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ struct ServeArgs {
4545
/// The port to bind this service to
4646
#[arg(short, long, env = "PORT", default_value_t = 80)]
4747
port: u16,
48+
/// The endpoint at which the GraphQL API should be served
49+
#[arg(long, env = "PREFIX_PATH", default_value = "/")]
50+
prefix_path: String,
4851
/// The endpoint to send OTLP metrics to
4952
#[arg(short, long, env = "METRICS_ENDPOINT")]
5053
metrics_endpoint: Option<Url>,
@@ -84,7 +87,7 @@ async fn main() {
8487
let schema = root_schema_builder()
8588
.data(ArgoServerUrl(args.argo_server_url))
8689
.finish();
87-
let router = setup_router(schema);
90+
let router = setup_router(schema, &args.prefix_path);
8891
serve(router, args.host, args.port).await.unwrap();
8992
}
9093
Cli::Schema(args) => {
@@ -101,17 +104,13 @@ async fn main() {
101104
}
102105

103106
/// Creates an [`axum::Router`] serving GraphiQL and sychronous GraphQL
104-
fn setup_router(schema: RootSchema) -> Router {
107+
fn setup_router(schema: RootSchema, prefix_path: &str) -> Router {
105108
#[allow(clippy::missing_docs_in_private_items)]
106-
const GRAPHQL_ENDPOINT: &str = "/";
107-
108109
Router::new().route(
109-
GRAPHQL_ENDPOINT,
110-
get(Html(
111-
GraphiQLSource::build().endpoint(GRAPHQL_ENDPOINT).finish(),
112-
))
113-
.post(graphql_handler)
114-
.with_state(schema),
110+
prefix_path,
111+
get(Html(GraphiQLSource::build().endpoint(prefix_path).finish()))
112+
.post(graphql_handler)
113+
.with_state(schema),
115114
)
116115
}
117116

0 commit comments

Comments
 (0)