Skip to content

Commit

Permalink
refactor: PreparedArgs api
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Aug 7, 2024
1 parent 278bc09 commit 25d96a8
Show file tree
Hide file tree
Showing 13 changed files with 1,771 additions and 1,238 deletions.
10 changes: 6 additions & 4 deletions libs/metagen/src/client_py/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn render_client_py(_config: &ClienPyGenConfig, tg: &Typegraph) -> anyhow::Resul
r#"
class QueryGraph(QueryGraphBase):
def __init__(self):
self.ty_to_gql_ty_map = {{"#
super().__init__({{"#
)?;
for ty_name in name_mapper.memo.borrow().deref().values() {
write!(
Expand All @@ -148,7 +148,7 @@ class QueryGraph(QueryGraphBase):
write!(
dest,
r#"
}}
}})
"#
)?;

Expand All @@ -163,9 +163,11 @@ class QueryGraph(QueryGraphBase):
fun.in_id.map(|id| data_types.get(&id).unwrap()),
fun.select_ty.map(|id| selection_names.get(&id).unwrap()),
) {
(Some(arg_ty), Some(select_ty)) => format!("self, args: {arg_ty}, select: {select_ty}"),
(Some(arg_ty), Some(select_ty)) => {
format!("self, args: typing.Union[{arg_ty}, PlaceholderArgs], select: {select_ty}")
}
// functions that return scalars don't need selections
(Some(arg_ty), None) => format!("self, args: {arg_ty}"),
(Some(arg_ty), None) => format!("self, args: typing.Union[{arg_ty}, PlaceholderArgs]"),
// not all functions have args (empty struct arg)
(None, Some(select_ty)) => format!("self, select: {select_ty}"),
(None, None) => "self".into(),
Expand Down
Loading

0 comments on commit 25d96a8

Please sign in to comment.