@@ -45,6 +45,9 @@ struct ServeArgs {
45
45
/// The port to bind this service to
46
46
#[ arg( short, long, env = "PORT" , default_value_t = 80 ) ]
47
47
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 ,
48
51
/// The endpoint to send OTLP metrics to
49
52
#[ arg( short, long, env = "METRICS_ENDPOINT" ) ]
50
53
metrics_endpoint : Option < Url > ,
@@ -84,7 +87,7 @@ async fn main() {
84
87
let schema = root_schema_builder ( )
85
88
. data ( ArgoServerUrl ( args. argo_server_url ) )
86
89
. finish ( ) ;
87
- let router = setup_router ( schema) ;
90
+ let router = setup_router ( schema, & args . prefix_path ) ;
88
91
serve ( router, args. host , args. port ) . await . unwrap ( ) ;
89
92
}
90
93
Cli :: Schema ( args) => {
@@ -101,17 +104,13 @@ async fn main() {
101
104
}
102
105
103
106
/// 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 {
105
108
#[ allow( clippy:: missing_docs_in_private_items) ]
106
- const GRAPHQL_ENDPOINT : & str = "/" ;
107
-
108
109
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) ,
115
114
)
116
115
}
117
116
0 commit comments