Skip to content

Commit fe0adbe

Browse files
author
Gil Mizrahi
authored
update to ndc-sdk-rs-0.2.1 (#520)
### What We want to update ndc-sdk-rs to 0.2.1, and it introduces several changes: 1. Error messages hasura/ndc-sdk-rs#15 2. Update ndc-spec to 0.1.5, which introduces breaking changes by adding newtype wrappers around string types ### How 1. For errors, follow hasura/ndc-sdk-rs#15 (comment) 2. For newtypes, go into type hell and fix the bugs by trying to put the ndc-models newtypes in the data structures, as they are more descriptive.
1 parent 58ec61f commit fe0adbe

File tree

74 files changed

+1013
-1092
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1013
-1092
lines changed

Cargo.lock

Lines changed: 16 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ similar_names = "allow"
3131
too_many_lines = "allow"
3232

3333
[workspace.dependencies]
34-
ndc-models = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.4" }
35-
ndc-sdk = { git = "https://github.com/hasura/ndc-sdk-rs.git", tag = "v0.1.4" }
36-
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.4" }
34+
ndc-models = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.5" }
35+
ndc-sdk = { git = "https://github.com/hasura/ndc-sdk-rs.git", tag = "v0.2.1" }
36+
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.5" }
3737

3838
anyhow = "1"
3939
async-trait = "0.1"
@@ -58,6 +58,7 @@ serde = "1"
5858
serde_json = "1"
5959
serde_yaml = "0.9"
6060
similar-asserts = "1"
61+
smol_str = "0.1"
6162
sqlformat = "0.2"
6263
sqlx = "0.7"
6364
tempfile = "3"

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
### Changed
1111

12+
- Support ndc-sdk-rs v0.2.1, including changes to error messages.
13+
[#520](https://github.com/hasura/ndc-postgres/pull/520)
14+
1215
### Fixed
1316

1417
## [v0.8.0]

crates/cli/src/native_operations.rs

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,15 @@ async fn create(
159159
.metadata
160160
.native_queries
161161
.0
162-
.insert(name, new_native_operation);
162+
.insert(name.into(), new_native_operation);
163163
}
164164
Override::No => {
165165
// Only insert if vacant.
166-
if let std::collections::btree_map::Entry::Vacant(entry) =
167-
configuration.metadata.native_queries.0.entry(name.clone())
166+
if let std::collections::btree_map::Entry::Vacant(entry) = configuration
167+
.metadata
168+
.native_queries
169+
.0
170+
.entry(name.clone().into())
168171
{
169172
entry.insert(new_native_operation);
170173
} else {
@@ -202,36 +205,46 @@ async fn create(
202205
.native_operations
203206
.queries
204207
.0
205-
.insert(name, new_native_operation);
208+
.insert(name.into(), new_native_operation);
206209
}
207210
configuration::version5::native_operations::Kind::Mutation => {
208211
configuration
209212
.metadata
210213
.native_operations
211214
.mutations
212215
.0
213-
.insert(name, new_native_operation);
216+
.insert(name.into(), new_native_operation);
214217
}
215218
},
216219
Override::No => {
217220
// Only insert if vacant.
218-
if let std::collections::btree_map::Entry::Vacant(entry) = match kind {
219-
configuration::version5::native_operations::Kind::Query => configuration
220-
.metadata
221-
.native_operations
222-
.queries
223-
.0
224-
.entry(name.clone()),
225-
configuration::version5::native_operations::Kind::Mutation => configuration
226-
.metadata
227-
.native_operations
228-
.mutations
229-
.0
230-
.entry(name.clone()),
231-
} {
232-
entry.insert(new_native_operation);
233-
} else {
234-
anyhow::bail!("A Native Operation with the name '{name}' already exists. To override, use the --override flag.");
221+
match kind {
222+
configuration::version5::native_operations::Kind::Query => {
223+
if let std::collections::btree_map::Entry::Vacant(entry) = configuration
224+
.metadata
225+
.native_operations
226+
.queries
227+
.0
228+
.entry(name.clone().into())
229+
{
230+
entry.insert(new_native_operation);
231+
} else {
232+
anyhow::bail!("A Native Operation with the name '{name}' already exists. To override, use the --override flag.");
233+
}
234+
}
235+
configuration::version5::native_operations::Kind::Mutation => {
236+
if let std::collections::btree_map::Entry::Vacant(entry) = configuration
237+
.metadata
238+
.native_operations
239+
.mutations
240+
.0
241+
.entry(name.clone().into())
242+
{
243+
entry.insert(new_native_operation);
244+
} else {
245+
anyhow::bail!("A Native Operation with the name '{name}' already exists. To override, use the --override flag.");
246+
}
247+
}
235248
}
236249
}
237250
}
@@ -270,7 +283,7 @@ async fn delete(
270283
))?,
271284
configuration::ParsedConfiguration::Version4(ref mut configuration) => {
272285
// Delete if exists and is of the same type, error if not.
273-
match configuration.metadata.native_queries.0.entry(name.clone()) {
286+
match configuration.metadata.native_queries.0.entry(name.into()) {
274287
std::collections::btree_map::Entry::Occupied(entry) => {
275288
let value = entry.get();
276289
if value.is_procedure {
@@ -307,7 +320,7 @@ async fn delete(
307320
.native_operations
308321
.mutations
309322
.0
310-
.entry(name.clone())
323+
.entry(name.into())
311324
{
312325
std::collections::btree_map::Entry::Occupied(entry) => {
313326
entry.remove_entry();
@@ -323,7 +336,7 @@ async fn delete(
323336
.native_operations
324337
.queries
325338
.0
326-
.entry(name.clone())
339+
.entry(name.into())
327340
{
328341
std::collections::btree_map::Entry::Occupied(entry) => {
329342
entry.remove_entry();

crates/configuration/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ license.workspace = true
88
workspace = true
99

1010
[dependencies]
11+
ndc-models = { workspace = true }
1112
query-engine-metadata = { path = "../query-engine/metadata" }
1213
query-engine-sql = { path = "../query-engine/sql" }
1314

@@ -18,6 +19,7 @@ prometheus = {workspace = true }
1819
schemars = { workspace = true, features = ["smol_str", "preserve_order"] }
1920
serde = { workspace = true }
2021
serde_json = { workspace = true, features = ["raw_value"] }
22+
smol_str = { workspace = true }
2123
sqlx = { workspace = true, features = ["json", "postgres", "runtime-tokio-rustls"] }
2224
thiserror = { workspace = true }
2325
tokio = { workspace = true, features = ["full"] }

0 commit comments

Comments
 (0)