Skip to content

Commit

Permalink
some logical fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop committed Sep 12, 2024
1 parent ff840bf commit 3ce51f6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 13 deletions.
66 changes: 66 additions & 0 deletions projects/ssddOnTop/Cargo.lock

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

3 changes: 3 additions & 0 deletions projects/ssddOnTop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ async-recursion = "1.1.1"

[dev-dependencies]
http-cache = "0.18.0"

[workspace]
members = []
16 changes: 5 additions & 11 deletions projects/ssddOnTop/src/blueprint/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,13 @@ impl TryFrom<&Config> for Blueprint {

fn fields_to_map(qry: &str, config: &Config, defs: Vec<Definition>) -> HashMap<FieldHash, Field> {
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<FieldHash, Field>,
defs: &[Definition],
) {
Expand All @@ -149,24 +148,22 @@ 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: {
let x = defs.iter().find_map(|def| match def {
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,
Expand All @@ -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(),
Expand Down Expand Up @@ -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 );
}
}
2 changes: 0 additions & 2 deletions projects/ssddOnTop/src/blueprint/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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<IR>,
Expand Down

0 comments on commit 3ce51f6

Please sign in to comment.