Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Aug 2, 2024
1 parent 62d534d commit 8ff17ec
Show file tree
Hide file tree
Showing 14 changed files with 1,270 additions and 1,186 deletions.
61 changes: 0 additions & 61 deletions examples/stuff.ts

This file was deleted.

4 changes: 2 additions & 2 deletions libs/metagen/src/client_py/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ class QueryGraph(QueryGraphBase):
let meta_method = node_metas.get(&fun.id).unwrap();

let node_type = match fun.effect {
EffectType::Create => "QueryNode",
EffectType::Update | EffectType::Delete | EffectType::Read => "MutationNode",
EffectType::Read => "QueryNode",
EffectType::Update | EffectType::Delete | EffectType::Create => "MutationNode",
};

write!(
Expand Down
11 changes: 5 additions & 6 deletions libs/metagen/src/client_py/static/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def convert_query_node_gql(
for key, val in node.args.items():
name = f"in{len(variables)}"
variables[name] = val
arg_row += f"{key}: ${name},"
out += f"({arg_row[:-1]})"
arg_row += f"{key}: ${name}, "
out += f"({arg_row[:-2]})"

if node.sub_nodes is not None:
sub_node_list = ""
Expand Down Expand Up @@ -223,9 +223,9 @@ def build_gql(
root_nodes += f" {key}: {convert_query_node_gql(node, variables)}\n"
args_row = ""
for key, val in variables.items():
args_row += f"${key}: {self.ty_to_gql_ty_map[val.type_name]},"
args_row += f"${key}: {self.ty_to_gql_ty_map[val.type_name]}, "

doc = f"{ty} {name}({args_row[:-1]}) {{\n{root_nodes}}}"
doc = f"{ty} {name}({args_row[:-2]}) {{\n{root_nodes}}}"
return (doc, {key: val.value for key, val in variables.items()})

def build_req(
Expand Down Expand Up @@ -258,7 +258,7 @@ def handle_response(self, res: GraphQLResponse):
if res.headers.get("content-type") != "application/json":
raise Exception("unexpected content-type in graphql response", res)
parsed = json.loads(res.body)
if parsed["errors"]:
if parsed.get("errors"):
raise Exception("graphql errors in response", parsed)
return parsed["data"]

Expand Down Expand Up @@ -304,7 +304,6 @@ def query(
opts: typing.Union[GraphQLTransportOptions, None] = None,
) -> typing.Dict[str, Out]:
doc, variables = self.build_gql({key: val for key, val in inp.items()}, "query")
print(doc, variables)
out = self.fetch(doc, variables, opts)
return out

Expand Down
4 changes: 2 additions & 2 deletions libs/metagen/src/client_ts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ export class QueryGraph extends QueryGraphBase {{
let meta_method = node_metas.get(&fun.id).unwrap();

let node_type = match fun.effect {
EffectType::Create => "QueryNode",
EffectType::Update | EffectType::Delete | EffectType::Read => "MutationNode",
EffectType::Read => "QueryNode",
EffectType::Update | EffectType::Delete | EffectType::Create => "MutationNode",
};

write!(
Expand Down
4 changes: 2 additions & 2 deletions libs/metagen/src/client_ts/static/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class GraphQLTransport {
return res.data as QueryDocOut<Doc>;
}

async mutation<Doc extends Record<string, QueryNode<unknown>>>(
async mutation<Doc extends Record<string, MutationNode<unknown>>>(
query: Doc,
options?: GraphQlTransportOptions,
): Promise<QueryDocOut<Doc>> {
Expand All @@ -116,7 +116,7 @@ export class GraphQLTransport {
[key, val],
) => [key, (val as MutationNode<unknown>).inner]),
),
"query",
"mutation",
);
const res = await this.fetch(doc, variables, options);
if ("errors" in res) {
Expand Down
Loading

0 comments on commit 8ff17ec

Please sign in to comment.