diff --git a/projects/ssddOnTop/Cargo.lock b/projects/ssddOnTop/Cargo.lock index 766906b..530415e 100644 --- a/projects/ssddOnTop/Cargo.lock +++ b/projects/ssddOnTop/Cargo.lock @@ -273,6 +273,17 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "async-signal" version = "0.2.10" @@ -686,6 +697,12 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "either" version = "1.13.0" @@ -1351,11 +1368,21 @@ dependencies = [ name = "macros" version = "0.1.0" dependencies = [ + "anyhow", + "macros_common", "proc-macro2", "quote", "syn", ] +[[package]] +name = "macros_common" +version = "0.1.0" +dependencies = [ + "async-graphql", + "schemars", +] + [[package]] name = "matchers" version = "0.1.0" @@ -2035,6 +2062,30 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -2090,6 +2141,17 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "serde_json" version = "1.0.128" @@ -2229,6 +2291,7 @@ dependencies = [ "anyhow", "async-graphql", "async-graphql-value", + "async-recursion", "async-trait", "bytes", "convert_case 0.6.0", @@ -2246,6 +2309,8 @@ dependencies = [ "hyper-util", "indenter", "indexmap", + "macros", + "macros_common", "moka", "nom", "num_cpus", @@ -2253,6 +2318,7 @@ dependencies = [ "prost-reflect", "reqwest", "reqwest-middleware", + "schemars", "serde", "serde_json", "serde_json_borrow", diff --git a/projects/ssddOnTop/Cargo.toml b/projects/ssddOnTop/Cargo.toml index 8188147..ebfdaa9 100644 --- a/projects/ssddOnTop/Cargo.toml +++ b/projects/ssddOnTop/Cargo.toml @@ -52,3 +52,6 @@ async-recursion = "1.1.1" [dev-dependencies] http-cache = "0.18.0" + +[workspace] +members = [] diff --git a/projects/ssddOnTop/src/blueprint/blueprint.rs b/projects/ssddOnTop/src/blueprint/blueprint.rs index e49d5e0..917d0ce 100644 --- a/projects/ssddOnTop/src/blueprint/blueprint.rs +++ b/projects/ssddOnTop/src/blueprint/blueprint.rs @@ -133,14 +133,13 @@ impl TryFrom<&Config> for Blueprint { fn fields_to_map(qry: &str, config: &Config, defs: Vec) -> HashMap { let mut fields = HashMap::new(); - populate_nested_field(config, qry, 0, &mut fields, &defs); + populate_nested_field(config, qry, &mut fields, &defs); fields } fn populate_nested_field( config: &Config, ty_name: &str, - field_id: usize, field_map: &mut HashMap, defs: &[Definition], ) { @@ -149,10 +148,8 @@ fn populate_nested_field( if let Some(ty) = config.types.get(ty_name) { for (field_name, field) in ty.fields.iter() { let field_name = FieldName(field_name.clone()); - populate_nested_field(config, field.ty_of.name(), field_id + 1, field_map, defs); - let mut arg_id = 0; + populate_nested_field(config, field.ty_of.name(), field_map, defs); let field = Field { - id: FieldId::new(field_id), name: field_name.clone(), type_of: field.ty_of.clone(), ir: { @@ -160,13 +157,13 @@ fn populate_nested_field( Definition::Interface(int) => Some( int.fields .iter() - .find(|f| field_name.0.eq(&f.name))? + .find(|f| field_name.0.eq(&f.name) && int.name.eq(ty_name))? .clone(), ), Definition::Object(obj) => Some( obj.fields .iter() - .find(|f| field_name.0.eq(&f.name))? + .find(|f| field_name.0.eq(&f.name) && obj.name.eq(ty_name))? .clone(), ), Definition::InputObject(_) => None, @@ -180,12 +177,9 @@ fn populate_nested_field( .iter() .map(|(arg_name, arg)| { let arg = Arg { - id: ArgId::new(arg_id), name: arg_name.clone(), type_of: arg.type_of.clone(), }; - arg_id += 1; - arg }) .collect(), @@ -214,6 +208,6 @@ mod test { .read(format!("{}/schema/schema.graphql", root)) .unwrap(); let blueprint = crate::blueprint::Blueprint::try_from(&config).unwrap(); - // println!("{:#?}", blueprint); + println!("{:#?}", blueprint.fields ); } } diff --git a/projects/ssddOnTop/src/blueprint/model.rs b/projects/ssddOnTop/src/blueprint/model.rs index 64fa53c..f3fbdf3 100644 --- a/projects/ssddOnTop/src/blueprint/model.rs +++ b/projects/ssddOnTop/src/blueprint/model.rs @@ -48,7 +48,6 @@ impl FieldId { #[derive(Clone, Debug)] pub struct Arg { - pub id: ArgId, pub name: String, pub type_of: crate::blueprint::wrapping_type::Type, } @@ -60,7 +59,6 @@ pub struct Flat(FieldId); #[derive(Clone, Debug)] pub struct Field { - pub id: FieldId, pub name: FieldName, pub type_of: crate::blueprint::wrapping_type::Type, pub ir: Option,