From 5826bd03180c5bb8f6fb33100cd9c6af5e1551eb Mon Sep 17 00:00:00 2001 From: Larko <59736843+Larkooo@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:04:11 +0700 Subject: [PATCH] feat; use graphiql & upgrade version (#2683) --- Cargo.lock | 65 ++++++++++++++++++++---------- crates/torii/graphql/Cargo.toml | 4 +- crates/torii/graphql/src/server.rs | 13 +++--- 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0012c75a7..3af88cd098 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1392,26 +1392,27 @@ dependencies = [ [[package]] name = "async-graphql" -version = "6.0.11" +version = "7.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "298a5d587d6e6fdb271bf56af2dc325a80eb291fd0fc979146584b9a05494a8c" +checksum = "0ba6d24703c5adc5ba9116901b92ee4e4c0643c01a56c4fd303f3818638d7449" dependencies = [ "async-graphql-derive", "async-graphql-parser", "async-graphql-value", "async-stream", "async-trait", - "base64 0.13.1", + "base64 0.22.1", "bytes", "chrono", "fast_chemail", "fnv", + "futures-timer", "futures-util", "handlebars", - "http 0.2.12", + "http 1.1.0", "indexmap 2.5.0", "mime", - "multer", + "multer 3.1.0", "num-traits 0.2.19", "once_cell", "pin-project-lite", @@ -1419,33 +1420,33 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "static_assertions", + "static_assertions_next", "tempfile", "thiserror", ] [[package]] name = "async-graphql-derive" -version = "6.0.11" +version = "7.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f329c7eb9b646a72f70c9c4b516c70867d356ec46cb00dcac8ad343fd006b0" +checksum = "a94c2d176893486bd37cd1b6defadd999f7357bf5804e92f510c08bcf16c538f" dependencies = [ "Inflector", "async-graphql-parser", "darling 0.20.10", - "proc-macro-crate 1.1.3", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "strum 0.25.0", + "strum 0.26.3", "syn 2.0.77", "thiserror", ] [[package]] name = "async-graphql-parser" -version = "6.0.11" +version = "7.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6139181845757fd6a73fbb8839f3d036d7150b798db0e9bb3c6e83cdd65bd53b" +checksum = "79272bdbf26af97866e149f05b2b546edb5c00e51b5f916289931ed233e208ad" dependencies = [ "async-graphql-value", "pest", @@ -1455,9 +1456,9 @@ dependencies = [ [[package]] name = "async-graphql-value" -version = "6.0.11" +version = "7.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "323a5143f5bdd2030f45e3f2e0c821c9b1d36e79cf382129c64299c50a7f3750" +checksum = "ef5ec94176a12a8cbe985cd73f2e54dc9c702c88c766bdef12f1f3a67cedbee1" dependencies = [ "bytes", "indexmap 2.5.0", @@ -1467,9 +1468,9 @@ dependencies = [ [[package]] name = "async-graphql-warp" -version = "6.0.11" +version = "7.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa68237ec9f2190cae295122ba45612b992658fbc372d142c6c6981cc70a9eac" +checksum = "0f08249c21cdc6a24408821c4ea5beb5d005de40d1f4f657bc9a3269ef63c7c2" dependencies = [ "async-graphql", "futures-util", @@ -6669,9 +6670,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.5.0" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" +checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" dependencies = [ "log", "pest", @@ -9563,6 +9564,23 @@ dependencies = [ "version_check", ] +[[package]] +name = "multer" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http 1.1.0", + "httparse", + "memchr", + "mime", + "spin 0.9.8", + "version_check", +] + [[package]] name = "multiaddr" version = "0.17.1" @@ -14043,6 +14061,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "static_assertions_next" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7beae5182595e9a8b683fa98c4317f956c9a2dec3b9716990d20023cc60c766" + [[package]] name = "str_stack" version = "0.1.0" @@ -14096,9 +14120,6 @@ name = "strum" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" -dependencies = [ - "strum_macros 0.25.3", -] [[package]] name = "strum" @@ -15919,7 +15940,7 @@ dependencies = [ "log", "mime", "mime_guess", - "multer", + "multer 2.1.0", "percent-encoding", "pin-project", "scoped-tls", diff --git a/crates/torii/graphql/Cargo.toml b/crates/torii/graphql/Cargo.toml index 4d31a89943..e34e21f1ac 100644 --- a/crates/torii/graphql/Cargo.toml +++ b/crates/torii/graphql/Cargo.toml @@ -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 diff --git a/crates/torii/graphql/src/server.rs b/crates/torii/graphql/src/server.rs index 4ac5f3dd78..d89e91dee7 100644 --- a/crates/torii/graphql/src/server.rs +++ b/crates/torii/graphql/src/server.rs @@ -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; @@ -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)