Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade ndc-spec to v0.1.4. #14

Merged
merged 4 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading