Skip to content

Commit

Permalink
fix: fix graphql playground URL (#2737)
Browse files Browse the repository at this point in the history
External url is now expected to be the graphql
url. Where the websocket may be added.
  • Loading branch information
glihm authored Nov 29, 2024
1 parent cd80507 commit 0fe329a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/torii/graphql/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
};

Expand Down

0 comments on commit 0fe329a

Please sign in to comment.