Skip to content

Commit

Permalink
Upgrade ndc-spec to v0.1.4. (#14)
Browse files Browse the repository at this point in the history
I also upgraded the Rust version used for development, for fun.
  • Loading branch information
SamirTalwar authored Jun 12, 2024
1 parent 266f4db commit 29adcb5
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 29 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
4 changes: 2 additions & 2 deletions crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
31 changes: 30 additions & 1 deletion crates/sdk/src/connector/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Connector for Example {

async fn get_capabilities() -> JsonResponse<models::CapabilitiesResponse> {
models::CapabilitiesResponse {
version: "0.1.3".into(),
version: "0.1.4".into(),
capabilities: models::Capabilities {
relationships: None,
query: models::QueryCapabilities {
Expand All @@ -60,6 +60,7 @@ impl Connector for Example {
nested_fields: models::NestedFieldCapabilities {
filter_by: None,
order_by: None,
aggregates: None,
},
},
mutation: models::MutationCapabilities {
Expand Down Expand Up @@ -122,3 +123,31 @@ 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<dyn Error + Send + Sync>> {
let state =
crate::default_main::init_server_state(Example::default(), PathBuf::new()).await?;
let app = crate::default_main::create_router::<Example>(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;
// ideally we would get this version from `ndc_models::VERSION`
assert_eq!(body.version, "0.1.4");
Ok(())
}
}
30 changes: 12 additions & 18 deletions flake.lock

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

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# the line, `use flake`.

{
description = "ndc-hub";
description = "ndc-sdk-rs";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 29adcb5

Please sign in to comment.