diff --git a/CHANGELOG.md b/CHANGELOG.md index fdd6424972a..17329a646aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,9 +40,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). #### Breaking - [2389](https://github.com/FuelLabs/fuel-core/pull/2258): Updated the `messageProof` GraphQL schema to return a non-nullable `MessageProof`. - -#### Breaking - [2154](https://github.com/FuelLabs/fuel-core/pull/2154): Transaction graphql endpoints use `TransactionType` instead of `fuel_tx::Transaction`. +- [2446](https://github.com/FuelLabs/fuel-core/pull/2446): Use graphiql instead of graphql-playground due to known vulnerability and stale development. ## [Version 0.40.0] diff --git a/Cargo.lock b/Cargo.lock index a3d5b110deb..77cc703905c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -352,6 +352,7 @@ dependencies = [ "fnv", "futures-timer", "futures-util", + "handlebars", "http 1.1.0", "indexmap 2.6.0", "mime", @@ -4401,6 +4402,20 @@ dependencies = [ "crunchy", ] +[[package]] +name = "handlebars" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" +dependencies = [ + "log", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror 1.0.69", +] + [[package]] name = "hash32" version = "0.2.1" @@ -6940,6 +6955,40 @@ dependencies = [ "ucd-trie", ] +[[package]] +name = "pest_derive" +version = "2.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "pest_meta" +version = "2.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" +dependencies = [ + "once_cell", + "pest", + "sha2 0.10.8", +] + [[package]] name = "petgraph" version = "0.6.5" diff --git a/bin/fuel-core/src/cli/run/graphql.rs b/bin/fuel-core/src/cli/run/graphql.rs index 5816b2ecbc0..4abce8922a1 100644 --- a/bin/fuel-core/src/cli/run/graphql.rs +++ b/bin/fuel-core/src/cli/run/graphql.rs @@ -31,7 +31,7 @@ pub struct GraphQLArgs { pub graphql_max_complexity: usize, /// The max recursive depth of GraphQL queries. - #[clap(long = "graphql-max-recursive-depth", default_value = "16", env)] + #[clap(long = "graphql-max-recursive-depth", default_value = "24", env)] pub graphql_max_recursive_depth: usize, /// The max resolver recursive depth of GraphQL queries. diff --git a/crates/fuel-core/Cargo.toml b/crates/fuel-core/Cargo.toml index cac6a58150b..8e3230df1fc 100644 --- a/crates/fuel-core/Cargo.toml +++ b/crates/fuel-core/Cargo.toml @@ -13,7 +13,7 @@ version = { workspace = true } [dependencies] anyhow = { workspace = true } async-graphql = { version = "7.0.11", features = [ - "playground", + "graphiql", "tracing", ], default-features = false } async-graphql-value = "7.0.11" diff --git a/crates/fuel-core/src/graphql_api/api_service.rs b/crates/fuel-core/src/graphql_api/api_service.rs index e9a1411085a..aeda75b4518 100644 --- a/crates/fuel-core/src/graphql_api/api_service.rs +++ b/crates/fuel-core/src/graphql_api/api_service.rs @@ -26,10 +26,7 @@ use crate::{ }, }; use async_graphql::{ - http::{ - playground_source, - GraphQLPlaygroundConfig, - }, + http::GraphiQLSource, Request, Response, }; @@ -278,16 +275,22 @@ where .extension(ViewExtension::new()) .finish(); + let graphql_endpoint = "/v1/graphql"; + let graphql_subscription_endpoint = "/v1/graphql-sub"; + + let graphql_playground = + || render_graphql_playground(graphql_endpoint, graphql_subscription_endpoint); + let router = Router::new() .route("/v1/playground", get(graphql_playground)) .route( - "/v1/graphql", + graphql_endpoint, post(graphql_handler) .layer(ConcurrencyLimitLayer::new(concurrency_limit)) .options(ok), ) .route( - "/v1/graphql-sub", + graphql_subscription_endpoint, post(graphql_subscription_handler).options(ok), ) .route("/v1/metrics", get(metrics)) @@ -325,10 +328,17 @@ where )) } -async fn graphql_playground() -> impl IntoResponse { - Html(playground_source(GraphQLPlaygroundConfig::new( - "/v1/graphql", - ))) +async fn render_graphql_playground( + endpoint: &str, + subscription_endpoint: &str, +) -> impl IntoResponse { + Html( + GraphiQLSource::build() + .endpoint(endpoint) + .subscription_endpoint(subscription_endpoint) + .title("Fuel Graphql Playground") + .finish(), + ) } async fn health() -> Json {