Skip to content

Commit

Permalink
Merge branch 'main' into update-tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath authored Oct 29, 2024
2 parents 0e13d7d + 2c67ac5 commit 2808ed5
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 203 deletions.
36 changes: 18 additions & 18 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
Expand Up @@ -161,7 +161,7 @@ tailcall-typedefs-common = { path = "./tailcall-typedefs-common" }
tonic-types = "0.12.1"
base64 = "0.22.1"
tailcall-hasher = { path = "tailcall-hasher" }
serde_json_borrow = "0.6.0"
serde_json_borrow = "0.7.0"
pluralizer = "0.4.0"
path-clean = "=1.0.1"
pathdiff = "0.2.1"
Expand Down
6 changes: 3 additions & 3 deletions npm/package-lock.json

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

29 changes: 24 additions & 5 deletions src/core/jit/fixtures/jp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::core::jit::builder::Builder;
use crate::core::jit::store::Store;
use crate::core::jit::synth::Synth;
use crate::core::jit::transform::InputResolver;
use crate::core::jit::{transform, OperationPlan, Variables};
use crate::core::jit::{transform, Field, OperationPlan, Variables};
use crate::core::json::{JsonLike, JsonObjectLike};
use crate::core::valid::Validator;
use crate::core::Transform;
Expand Down Expand Up @@ -119,10 +119,11 @@ impl<'a, Value: Deserialize<'a> + Clone + 'a + JsonLike<'a> + std::fmt::Debug> J
let ProcessedTestData { posts, users } = self.test_data.to_processed();
let vars = self.vars.clone();

let posts_id = self.plan.find_field_path(&["posts"]).unwrap().id.to_owned();
let users_id = self
.plan
.find_field_path(&["posts", "user"])
let posts_id = find_field_path(&self.plan, &["posts"])
.unwrap()
.id
.to_owned();
let users_id = find_field_path(&self.plan, &["posts", "user"])
.unwrap()
.id
.to_owned();
Expand All @@ -137,3 +138,21 @@ impl<'a, Value: Deserialize<'a> + Clone + 'a + JsonLike<'a> + std::fmt::Debug> J
Synth::new(&self.plan, store, vars)
}
}

/// Search for a field by specified path of nested fields
pub fn find_field_path<'a, S: AsRef<str>, T>(
plan: &'a OperationPlan<T>,
path: &[S],
) -> Option<&'a Field<T>> {
match path.split_first() {
None => None,
Some((name, path)) => {
let field = plan.iter_dfs().find(|field| field.name == name.as_ref())?;
if path.is_empty() {
Some(field)
} else {
find_field_path(plan, path)
}
}
}
}
15 changes: 0 additions & 15 deletions src/core/jit/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,21 +366,6 @@ impl<Input> OperationPlan<Input> {
DFS { stack: vec![self.selection.iter()] }
}

/// Search for a field by specified path of nested fields
pub fn find_field_path<S: AsRef<str>>(&self, path: &[S]) -> Option<&Field<Input>> {
match path.split_first() {
None => None,
Some((name, path)) => {
let field = self.iter_dfs().find(|field| field.name == name.as_ref())?;
if path.is_empty() {
Some(field)
} else {
self.find_field_path(path)
}
}
}
}

/// Returns number of fields in plan
pub fn size(&self) -> usize {
fn count<A>(field: &Field<A>) -> usize {
Expand Down
Loading

0 comments on commit 2808ed5

Please sign in to comment.