From 3672be0c1fa991dc56514045636d95e2662fb5e7 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Mon, 26 Feb 2024 08:49:33 +0100 Subject: [PATCH] Move `v2_compat` behind a Cargo feature. This allows us to remove `gdc_rust_types` from the dependency tree if we don't need it. --- rust-connector-sdk/Cargo.toml | 7 +++++-- rust-connector-sdk/src/default_main.rs | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/rust-connector-sdk/Cargo.toml b/rust-connector-sdk/Cargo.toml index 9d74a70cd..b8e25cde7 100644 --- a/rust-connector-sdk/Cargo.toml +++ b/rust-connector-sdk/Cargo.toml @@ -11,8 +11,11 @@ path = "src/lib.rs" name = "ndc_hub_example" path = "bin/main.rs" +[features] +v2_compat = ["dep:gdc_rust_types", "dep:indexmap"] + [dependencies] -gdc_rust_types = { git = "https://github.com/hasura/gdc_rust_types.git", rev = "3273434" } +gdc_rust_types = { git = "https://github.com/hasura/gdc_rust_types.git", rev = "3273434", optional = true } # used for v2_compat ndc-client = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.18" } ndc-test = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.18" } @@ -22,7 +25,7 @@ axum-extra = "^0.8.0" bytes = "1.5.0" clap = { version = "^4.4.7", features = ["derive", "env"] } http = "^0.2" -indexmap = "2" +indexmap = { version = "2", optional = true } # used for v2_compat mime = "0.3.17" opentelemetry = { version = "^0.20", default-features = false, features = ["rt-tokio", "trace"] } opentelemetry-http = "0.9.0" diff --git a/rust-connector-sdk/src/default_main.rs b/rust-connector-sdk/src/default_main.rs index f3fccd7a5..4ba5fa629 100644 --- a/rust-connector-sdk/src/default_main.rs +++ b/rust-connector-sdk/src/default_main.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "v2_compat")] mod v2_compat; use std::error::Error; @@ -180,11 +181,10 @@ where serve_command.service_token_secret.clone(), ); - let router = if serve_command.enable_v2_compatibility { + #[cfg(feature = "v2_compat")] + let router = { let v2_router = create_v2_router(server_state, serve_command.service_token_secret.clone()); Router::new().merge(router).nest("/v2", v2_router) - } else { - router }; let port = serve_command.port; @@ -326,6 +326,7 @@ where )) } +#[cfg(feature = "v2_compat")] pub fn create_v2_router( state: ServerState, service_token_secret: Option,