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

feat(metagen/client): Add file upload support #854

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/common/src/typegraph/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::visitor::{
pub fn validate_typegraph(tg: &Typegraph) -> Vec<ValidatorError> {
let context = ValidatorContext { typegraph: tg };
let validator = Validator::default();
tg.traverse_types(validator, &context, Layer).unwrap()
tg.traverse_types(validator, &context, Layer, 0).unwrap()
}

#[derive(Debug)]
Expand Down
4 changes: 3 additions & 1 deletion src/common/src/typegraph/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl Typegraph {
visitor: V,
context: &'a V::Context,
layer: L,
root: u32,
) -> Option<V::Return>
where
V: TypeVisitor<'a> + Sized + 'a,
Expand All @@ -67,7 +68,7 @@ impl Typegraph {
layer,
};
traversal
.visit_type(0, context)
.visit_type(root, context)
.or_else(|| traversal.visitor.take_result())
}
}
Expand Down Expand Up @@ -370,6 +371,7 @@ pub enum Edge<'a> {
}

pub enum VisitResult<T> {
/// Continue the traversal. The boolean indicates whether to continue deeper.
Continue(bool),
Return(T),
}
Expand Down
9 changes: 8 additions & 1 deletion src/metagen/src/client_ts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ export class QueryGraph extends _QueryGraphBase {{
EffectType::Update | EffectType::Delete | EffectType::Create => "MutationNode",
};

let in_files = fun
.in_files
.iter()
.map(|path| path.0.iter().map(ToString::to_string).collect::<Vec<_>>())
.collect::<Vec<_>>();
let in_files = serde_json::to_string(&in_files)?;

write!(
dest,
r#"
Expand All @@ -200,7 +207,7 @@ export class QueryGraph extends _QueryGraphBase {{
[["{node_name}", nodeMetas.{meta_method}]],
"$q",
)[0];
return new {node_type}(inner) as {node_type}<{out_ty_name}>;
return new {node_type}(inner, {in_files}) as {node_type}<{out_ty_name}>;
}}"#
)?;
}
Expand Down
Loading
Loading