From 0fe329a3c094db60b415d33b0779b90003c8968f Mon Sep 17 00:00:00 2001 From: glihm Date: Fri, 29 Nov 2024 12:18:13 -0600 Subject: [PATCH] fix: fix graphql playground URL (#2737) External url is now expected to be the graphql url. Where the websocket may be added. --- crates/torii/graphql/src/server.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/torii/graphql/src/server.rs b/crates/torii/graphql/src/server.rs index 6121f492fe..812a3cb5c8 100644 --- a/crates/torii/graphql/src/server.rs +++ b/crates/torii/graphql/src/server.rs @@ -48,20 +48,21 @@ fn graphql_filter( }, ); + // If an external URL is provided, we are expecting the GraphQL endpoint to be given. + // Hence, we don't have to append "/graphql" to the URL. let (graphql_endpoint, subscription_endpoint) = if let Some(external_url) = external_url { - let mut graphql_url = external_url; - graphql_url.set_path("graphql"); - + let graphql_url = external_url; let mut websocket_url = graphql_url.clone(); - websocket_url.set_path("ws"); + websocket_url.set_path(&format!("{}/ws", websocket_url.path())); let _ = websocket_url.set_scheme(match websocket_url.scheme() { "https" => "wss", "http" => "ws", _ => panic!("Invalid URL scheme - must be http or https"), }); - - (graphql_url.path().to_string(), websocket_url.to_string()) + (graphql_url.to_string(), websocket_url.to_string()) } else { + // Otherwise, we are running the GraphQL server locally and we need to + // append "/graphql" to the URL. ("graphql".to_string(), "graphql/ws".to_string()) };