From d22dde53b3ef05f78a25dd7ddf51955b75256088 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Tue, 4 Jun 2024 10:34:02 +0200 Subject: [PATCH 1/4] Upgrade ndc-spec to v0.1.4. I also upgraded the Rust version used for development, for fun. --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- crates/sdk/Cargo.toml | 4 ++-- flake.lock | 30 ++++++++++++------------------ flake.nix | 2 +- rust-toolchain.toml | 2 +- 6 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be481c4..e3a6d64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -954,7 +954,7 @@ dependencies = [ [[package]] name = "ndc-models" version = "0.1.3" -source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.3#b9316d206a6aece470531937f6e1ea9223e88122" +source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.4#622c643b4f0b6bbe4601c0f065d6d93a4bd3e9db" dependencies = [ "indexmap 2.2.6", "schemars", @@ -965,7 +965,7 @@ dependencies = [ [[package]] name = "ndc-sdk" -version = "0.1.3" +version = "0.1.4" dependencies = [ "async-trait", "axum", @@ -999,7 +999,7 @@ dependencies = [ [[package]] name = "ndc-test" version = "0.1.3" -source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.3#b9316d206a6aece470531937f6e1ea9223e88122" +source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.4#622c643b4f0b6bbe4601c0f065d6d93a4bd3e9db" dependencies = [ "async-trait", "clap", diff --git a/Cargo.toml b/Cargo.toml index 3087cf3..b1cf187 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] resolver = "2" -package.version = "0.1.3" +package.version = "0.1.4" package.edition = "2021" package.license = "Apache-2.0" diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index 4923864..451ca0e 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -24,8 +24,8 @@ rustls = ["reqwest/rustls"] ndc-test = ["dep:ndc-test"] [dependencies] -ndc-models = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.3" } -ndc-test = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.3", optional = true } +ndc-models = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.4" } +ndc-test = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.4", optional = true } async-trait = "0.1.79" axum = { version = "0.6.20", features = ["http2"] } diff --git a/flake.lock b/flake.lock index 2bbfe00..1eaaa44 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,14 @@ "nodes": { "crane": { "inputs": { - "nixpkgs": [ - "nixpkgs" - ] + "nixpkgs": ["nixpkgs"] }, "locked": { - "lastModified": 1712681629, - "narHash": "sha256-bMDXn4AkTXLCpoZbII6pDGoSeSe9gI87jxPsHRXgu/E=", + "lastModified": 1715274763, + "narHash": "sha256-3Iv1PGHJn9sV3HO4FlOVaaztOxa9uGLfOmUWrH7v7+A=", "owner": "ipetkov", "repo": "crane", - "rev": "220387ac8e99cbee0ca4c95b621c4bc782b6a235", + "rev": "27025ab71bdca30e7ed0a16c88fd74c5970fc7f5", "type": "github" }, "original": { @@ -40,11 +38,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1712742472, - "narHash": "sha256-EVubu9UGPhayvDit0KYKysZiXUo2BRyd6v7bNoCfkrI=", + "lastModified": 1715859993, + "narHash": "sha256-vLp62qr+t+Kzp4HsLgIlSiGaBF4R28VPUasWhF1RCnA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f9cee3306b1c7b94459e03cefc94f522f74d4f11", + "rev": "2eef017af08b91e353849dfe58436684e169b71d", "type": "github" }, "original": { @@ -63,19 +61,15 @@ }, "rust-overlay": { "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ] + "flake-utils": ["flake-utils"], + "nixpkgs": ["nixpkgs"] }, "locked": { - "lastModified": 1712715149, - "narHash": "sha256-uOx7GaLV+5hekAYtm/CBr627Pi7+d1Yh70hwKmVjYYo=", + "lastModified": 1715825775, + "narHash": "sha256-7np2/EEr5Xm8IuKWQ43q8AA1Lb6Us2BW6rYMxGrInIg=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "9ef1eca23bee5fb8080863909af3802130b2ee57", + "rev": "55f468b3d49c5d3321e85f2f9b1158476a2a90fb", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index a526f9c..737bbea 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,7 @@ # the line, `use flake`. { - description = "ndc-hub"; + description = "ndc-sdk-rs"; inputs = { flake-utils.url = "github:numtide/flake-utils"; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7abec8a..71eb619 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.77.2" +channel = "1.78.0" profile = "default" # see https://rust-lang.github.io/rustup/concepts/profiles.html components = ["rust-analyzer", "rust-src"] # see https://rust-lang.github.io/rustup/concepts/components.html From f7bb83659f76683f7acac6e233c0700e16eca621 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Tue, 4 Jun 2024 11:21:43 +0200 Subject: [PATCH 2/4] Point at the branch for now. --- Cargo.lock | 8 ++++---- crates/sdk/Cargo.toml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e3a6d64..5c86130 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -953,8 +953,8 @@ dependencies = [ [[package]] name = "ndc-models" -version = "0.1.3" -source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.4#622c643b4f0b6bbe4601c0f065d6d93a4bd3e9db" +version = "0.1.4" +source = "git+http://github.com/hasura/ndc-spec.git?branch=samirtalwar/bump#ba1559e131f5cc8d0563fbbc947508ec17dcd91e" dependencies = [ "indexmap 2.2.6", "schemars", @@ -998,8 +998,8 @@ dependencies = [ [[package]] name = "ndc-test" -version = "0.1.3" -source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.4#622c643b4f0b6bbe4601c0f065d6d93a4bd3e9db" +version = "0.1.4" +source = "git+http://github.com/hasura/ndc-spec.git?branch=samirtalwar/bump#ba1559e131f5cc8d0563fbbc947508ec17dcd91e" dependencies = [ "async-trait", "clap", diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index 451ca0e..3970f67 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -24,8 +24,8 @@ rustls = ["reqwest/rustls"] ndc-test = ["dep:ndc-test"] [dependencies] -ndc-models = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.4" } -ndc-test = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.4", optional = true } +ndc-models = { git = "http://github.com/hasura/ndc-spec.git", branch = "samirtalwar/bump" } +ndc-test = { git = "http://github.com/hasura/ndc-spec.git", branch = "samirtalwar/bump", optional = true } async-trait = "0.1.79" axum = { version = "0.6.20", features = ["http2"] } From 63b6ee4eb6973de67fd080e2e68ac9d314ff16a0 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Tue, 4 Jun 2024 11:21:51 +0200 Subject: [PATCH 3/4] Update the capabilities response for the example. --- crates/sdk/src/connector/example.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/crates/sdk/src/connector/example.rs b/crates/sdk/src/connector/example.rs index dd19b31..fecf26e 100644 --- a/crates/sdk/src/connector/example.rs +++ b/crates/sdk/src/connector/example.rs @@ -50,7 +50,7 @@ impl Connector for Example { async fn get_capabilities() -> JsonResponse { models::CapabilitiesResponse { - version: "0.1.3".into(), + version: "0.1.4".into(), capabilities: models::Capabilities { relationships: None, query: models::QueryCapabilities { @@ -122,3 +122,30 @@ impl Connector for Example { todo!() } } + +#[cfg(test)] +mod tests { + use std::error::Error; + use std::path::PathBuf; + + use axum_test_helper::TestClient; + use http::StatusCode; + + use super::*; + + #[tokio::test] + async fn capabilities_match_ndc_spec_version() -> Result<(), Box> { + let state = + crate::default_main::init_server_state(Example::default(), PathBuf::new()).await?; + let app = crate::default_main::create_router::(state, None); + + let client = TestClient::new(app); + let response = client.get("/capabilities").send().await; + + assert_eq!(response.status(), StatusCode::OK); + + let body: ndc_models::CapabilitiesResponse = response.json().await; + assert_eq!(body.version, ndc_models::VERSION); + Ok(()) + } +} From 80a2ef3454060e77e635754327a94290e1c063a2 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Wed, 12 Jun 2024 14:48:33 +0200 Subject: [PATCH 4/4] Bump to v0.1.4. It works! I think. --- Cargo.lock | 4 ++-- crates/sdk/Cargo.toml | 4 ++-- crates/sdk/src/connector/example.rs | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c86130..8bee3a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -954,7 +954,7 @@ dependencies = [ [[package]] name = "ndc-models" version = "0.1.4" -source = "git+http://github.com/hasura/ndc-spec.git?branch=samirtalwar/bump#ba1559e131f5cc8d0563fbbc947508ec17dcd91e" +source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.4#20172e3b2552b78d16dbafcd047f559ced420309" dependencies = [ "indexmap 2.2.6", "schemars", @@ -999,7 +999,7 @@ dependencies = [ [[package]] name = "ndc-test" version = "0.1.4" -source = "git+http://github.com/hasura/ndc-spec.git?branch=samirtalwar/bump#ba1559e131f5cc8d0563fbbc947508ec17dcd91e" +source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.4#20172e3b2552b78d16dbafcd047f559ced420309" dependencies = [ "async-trait", "clap", diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index 3970f67..451ca0e 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -24,8 +24,8 @@ rustls = ["reqwest/rustls"] ndc-test = ["dep:ndc-test"] [dependencies] -ndc-models = { git = "http://github.com/hasura/ndc-spec.git", branch = "samirtalwar/bump" } -ndc-test = { git = "http://github.com/hasura/ndc-spec.git", branch = "samirtalwar/bump", optional = true } +ndc-models = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.4" } +ndc-test = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.4", optional = true } async-trait = "0.1.79" axum = { version = "0.6.20", features = ["http2"] } diff --git a/crates/sdk/src/connector/example.rs b/crates/sdk/src/connector/example.rs index fecf26e..ce7486a 100644 --- a/crates/sdk/src/connector/example.rs +++ b/crates/sdk/src/connector/example.rs @@ -60,6 +60,7 @@ impl Connector for Example { nested_fields: models::NestedFieldCapabilities { filter_by: None, order_by: None, + aggregates: None, }, }, mutation: models::MutationCapabilities { @@ -145,7 +146,8 @@ mod tests { assert_eq!(response.status(), StatusCode::OK); let body: ndc_models::CapabilitiesResponse = response.json().await; - assert_eq!(body.version, ndc_models::VERSION); + // ideally we would get this version from `ndc_models::VERSION` + assert_eq!(body.version, "0.1.4"); Ok(()) } }