Skip to content

Commit

Permalink
feat; use graphiql & upgrade version (#2683)
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo authored Nov 13, 2024
1 parent cbdd2f0 commit 5826bd0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 30 deletions.
65 changes: 43 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/torii/graphql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ version.workspace = true

[dependencies]
anyhow.workspace = true
async-graphql = { version = "6.0.7", features = [ "chrono", "dynamic-schema" ] }
async-graphql-warp = "6.0.7"
async-graphql = { version = "7.0.11", features = [ "chrono", "dynamic-schema" ] }
async-graphql-warp = "7.0.11"
async-recursion = "1.0.5"
base64.workspace = true
chrono.workspace = true
Expand Down
13 changes: 7 additions & 6 deletions crates/torii/graphql/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::net::SocketAddr;

use async_graphql::dynamic::Schema;
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
use async_graphql::http::GraphiQLSource;
use async_graphql::Request;
use async_graphql_warp::graphql_subscription;
use serde_json::json;
Expand Down Expand Up @@ -65,11 +65,12 @@ fn graphql_filter(
};

let playground_filter = warp::path("graphql").map(move || {
warp::reply::html(playground_source(
// NOTE: GraphQL Playground currently doesn't support relative urls for the
// subscription endpoint.
GraphQLPlaygroundConfig::new("").subscription_endpoint(subscription_endpoint.as_str()),
))
warp::reply::html(
GraphiQLSource::build()
.endpoint("/graphql")
.subscription_endpoint(subscription_endpoint.as_str())
.finish(),
)
});

graphql_subscription(schema).or(graphql_post).or(playground_filter)
Expand Down

0 comments on commit 5826bd0

Please sign in to comment.