-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix graphql playground URL #2737
Conversation
External url is now expected to be the graphql url. Where the websocket may be added.
WalkthroughOhayo, sensei! This pull request modifies the Changes
Possibly related PRs
Suggested reviewers
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
crates/torii/graphql/src/server.rs (1)
64-66
: Consider using constants for endpoint paths, sensei!The hardcoded strings could be moved to constants at the module level for better maintainability.
+const LOCAL_GRAPHQL_ENDPOINT: &str = "graphql"; +const LOCAL_WS_ENDPOINT: &str = "graphql/ws"; + // ... - ("graphql".to_string(), "graphql/ws".to_string()) + (LOCAL_GRAPHQL_ENDPOINT.to_string(), LOCAL_WS_ENDPOINT.to_string())
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
crates/torii/graphql/src/server.rs
(1 hunks)
🔇 Additional comments (2)
crates/torii/graphql/src/server.rs (2)
51-52
: Ohayo! The comment accurately explains the behavioral change.
The comment clearly documents why we don't append "/graphql" anymore when using an external URL.
54-62
: Verify URL handling with different GraphQL clients.
The URL construction changes might affect various GraphQL clients differently. Let's verify the usage patterns in the codebase.
✅ Verification successful
Based on the search results, I can now generate the final response as the code shows consistent URL handling patterns:
URL construction is correctly implemented for both local and external GraphQL endpoints
The codebase handles URL construction consistently:
- For external URLs (
external_url
provided), it preserves the original path and only appends/ws
for WebSocket - For local URLs, it uses the standard
/graphql
and/graphql/ws
paths - All GraphQL clients in the codebase use these paths consistently through the proxy handler
The changes are safe and follow established patterns used by GraphQL clients.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for GraphQL client implementations and URL usage patterns
rg -A 5 "graphql|GraphQL" --type rust
# Look for any hardcoded GraphQL paths that might need updating
rg "/graphql" --type rust
Length of output: 55652
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"), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider more graceful error handling for URL schemes, sensei!
The current implementation panics on invalid URL schemes. Consider returning a Result instead to handle this more gracefully.
- _ => panic!("Invalid URL scheme - must be http or https"),
+ scheme => Err(format!("Invalid URL scheme '{}' - must be http or https", scheme))?
Committable suggestion skipped: line range outside the PR's diff.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2737 +/- ##
=======================================
Coverage 56.47% 56.47%
=======================================
Files 421 421
Lines 53976 53974 -2
=======================================
+ Hits 30482 30484 +2
+ Misses 23494 23490 -4 ☔ View full report in Codecov by Sentry. |
External url is now expected to be the graphql url. Where the websocket may be added.
Summary by CodeRabbit