Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Jan 3, 2025
1 parent 2acaff7 commit cd7db98
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 112 deletions.
21 changes: 0 additions & 21 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ members = [
"src/xtask",
"src/substantial",
"src/metagen-client-rs",
"tests/metagen/typegraphs/sample/rs",
"tests/metagen/typegraphs/sample/rs_upload",
]

exclude = [
"tests/runtimes/wasm_reflected/rust",
"tests/runtimes/wasm_wire/rust",
"tests/metagen/typegraphs/sample/rs",
"tests/metagen/typegraphs/sample/rs_upload",
"src/pyrt_wit_wire",
]
Expand Down
6 changes: 6 additions & 0 deletions src/metagen-client-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name = "metagen-client"
version.workspace = true
edition.workspace = true

# this allows us to exclude the rust files
# from the dockerfile while keeping the Cargo.toml
# for cargo chef. Useful to improve cache hit in docker
[lib]
path = "src/lib.rs"

[dependencies]
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
Expand Down
232 changes: 143 additions & 89 deletions tests/metagen/typegraphs/sample/py/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ class NodeDescs:
@staticmethod
def scalar():
return NodeMeta()

@staticmethod
def Post():
return NodeMeta(
Expand Down Expand Up @@ -937,29 +937,42 @@ def RootMixedUnionFn():
},
)


UserIdStringUuid = str

PostSlugString = str

Post = typing.TypedDict("Post", {
"id": UserIdStringUuid,
"slug": PostSlugString,
"title": PostSlugString,
}, total=False)

RootCompositeArgsFnInput = typing.TypedDict("RootCompositeArgsFnInput", {
"id": PostSlugString,
}, total=False)
Post = typing.TypedDict(
"Post",
{
"id": UserIdStringUuid,
"slug": PostSlugString,
"title": PostSlugString,
},
total=False,
)

RootCompositeArgsFnInput = typing.TypedDict(
"RootCompositeArgsFnInput",
{
"id": PostSlugString,
},
total=False,
)

UserEmailStringEmail = str

UserPostsPostList = typing.List[Post]

User = typing.TypedDict("User", {
"id": UserIdStringUuid,
"email": UserEmailStringEmail,
"posts": UserPostsPostList,
}, total=False)
User = typing.TypedDict(
"User",
{
"id": UserIdStringUuid,
"email": UserEmailStringEmail,
"posts": UserPostsPostList,
},
total=False,
)

RootScalarUnionFnOutputT1Integer = int

Expand All @@ -983,111 +996,152 @@ def RootMixedUnionFn():
]



PostSelections = typing.TypedDict("PostSelections", {
"_": SelectionFlags,
"id": ScalarSelectNoArgs,
"slug": ScalarSelectNoArgs,
"title": ScalarSelectNoArgs,
}, total=False)

UserSelections = typing.TypedDict("UserSelections", {
"_": SelectionFlags,
"id": ScalarSelectNoArgs,
"email": ScalarSelectNoArgs,
"posts": CompositeSelectNoArgs["PostSelections"],
}, total=False)

RootCompositeUnionFnOutputSelections = typing.TypedDict("RootCompositeUnionFnOutputSelections", {
"_": SelectionFlags,
"post": CompositeSelectNoArgs["PostSelections"],
"user": CompositeSelectNoArgs["UserSelections"],
}, total=False)

RootMixedUnionFnOutputSelections = typing.TypedDict("RootMixedUnionFnOutputSelections", {
"_": SelectionFlags,
"post": CompositeSelectNoArgs["PostSelections"],
"user": CompositeSelectNoArgs["UserSelections"],
}, total=False)
PostSelections = typing.TypedDict(
"PostSelections",
{
"_": SelectionFlags,
"id": ScalarSelectNoArgs,
"slug": ScalarSelectNoArgs,
"title": ScalarSelectNoArgs,
},
total=False,
)

UserSelections = typing.TypedDict(
"UserSelections",
{
"_": SelectionFlags,
"id": ScalarSelectNoArgs,
"email": ScalarSelectNoArgs,
"posts": CompositeSelectNoArgs["PostSelections"],
},
total=False,
)

RootCompositeUnionFnOutputSelections = typing.TypedDict(
"RootCompositeUnionFnOutputSelections",
{
"_": SelectionFlags,
"post": CompositeSelectNoArgs["PostSelections"],
"user": CompositeSelectNoArgs["UserSelections"],
},
total=False,
)

RootMixedUnionFnOutputSelections = typing.TypedDict(
"RootMixedUnionFnOutputSelections",
{
"_": SelectionFlags,
"post": CompositeSelectNoArgs["PostSelections"],
"user": CompositeSelectNoArgs["UserSelections"],
},
total=False,
)


class QueryGraph(QueryGraphBase):
def __init__(self):
super().__init__({
"UserIdStringUuid": "String!",
"PostSlugString": "String!",
"post": "post!",
"user": "user!",
})

super().__init__(
{
"UserIdStringUuid": "String!",
"PostSlugString": "String!",
"post": "post!",
"user": "user!",
}
)

def get_user(self, select: UserSelections) -> QueryNode[User]:
node = selection_to_nodes(
{"getUser": select},
{"getUser": NodeDescs.RootGetUserFn},
"$q"
{"getUser": select}, {"getUser": NodeDescs.RootGetUserFn}, "$q"
)[0]
return QueryNode(node.node_name, node.instance_name, node.args, node.sub_nodes, node.files)
return QueryNode(
node.node_name, node.instance_name, node.args, node.sub_nodes, node.files
)

def get_posts(self, select: PostSelections) -> QueryNode[Post]:
node = selection_to_nodes(
{"getPosts": select},
{"getPosts": NodeDescs.RootGetPostsFn},
"$q"
{"getPosts": select}, {"getPosts": NodeDescs.RootGetPostsFn}, "$q"
)[0]
return QueryNode(node.node_name, node.instance_name, node.args, node.sub_nodes, node.files)
return QueryNode(
node.node_name, node.instance_name, node.args, node.sub_nodes, node.files
)

def scalar_no_args(self) -> QueryNode[PostSlugString]:
node = selection_to_nodes(
{"scalarNoArgs": True},
{"scalarNoArgs": NodeDescs.RootScalarNoArgsFn},
"$q"
{"scalarNoArgs": True}, {"scalarNoArgs": NodeDescs.RootScalarNoArgsFn}, "$q"
)[0]
return QueryNode(node.node_name, node.instance_name, node.args, node.sub_nodes, node.files)
return QueryNode(
node.node_name, node.instance_name, node.args, node.sub_nodes, node.files
)

def scalar_args(self, args: typing.Union[Post, PlaceholderArgs]) -> MutationNode[PostSlugString]:
def scalar_args(
self, args: typing.Union[Post, PlaceholderArgs]
) -> MutationNode[PostSlugString]:
node = selection_to_nodes(
{"scalarArgs": args},
{"scalarArgs": NodeDescs.RootScalarArgsFn},
"$q"
{"scalarArgs": args}, {"scalarArgs": NodeDescs.RootScalarArgsFn}, "$q"
)[0]
return MutationNode(node.node_name, node.instance_name, node.args, node.sub_nodes, node.files)
return MutationNode(
node.node_name, node.instance_name, node.args, node.sub_nodes, node.files
)

def composite_no_args(self, select: PostSelections) -> MutationNode[Post]:
node = selection_to_nodes(
{"compositeNoArgs": select},
{"compositeNoArgs": NodeDescs.RootCompositeNoArgsFn},
"$q"
{"compositeNoArgs": select},
{"compositeNoArgs": NodeDescs.RootCompositeNoArgsFn},
"$q",
)[0]
return MutationNode(node.node_name, node.instance_name, node.args, node.sub_nodes, node.files)
return MutationNode(
node.node_name, node.instance_name, node.args, node.sub_nodes, node.files
)

def composite_args(self, args: typing.Union[RootCompositeArgsFnInput, PlaceholderArgs], select: PostSelections) -> MutationNode[Post]:
def composite_args(
self,
args: typing.Union[RootCompositeArgsFnInput, PlaceholderArgs],
select: PostSelections,
) -> MutationNode[Post]:
node = selection_to_nodes(
{"compositeArgs": (args, select)},
{"compositeArgs": NodeDescs.RootCompositeArgsFn},
"$q"
{"compositeArgs": (args, select)},
{"compositeArgs": NodeDescs.RootCompositeArgsFn},
"$q",
)[0]
return MutationNode(node.node_name, node.instance_name, node.args, node.sub_nodes, node.files)
return MutationNode(
node.node_name, node.instance_name, node.args, node.sub_nodes, node.files
)

def scalar_union(self, args: typing.Union[RootCompositeArgsFnInput, PlaceholderArgs]) -> QueryNode[RootScalarUnionFnOutput]:
def scalar_union(
self, args: typing.Union[RootCompositeArgsFnInput, PlaceholderArgs]
) -> QueryNode[RootScalarUnionFnOutput]:
node = selection_to_nodes(
{"scalarUnion": args},
{"scalarUnion": NodeDescs.RootScalarUnionFn},
"$q"
{"scalarUnion": args}, {"scalarUnion": NodeDescs.RootScalarUnionFn}, "$q"
)[0]
return QueryNode(node.node_name, node.instance_name, node.args, node.sub_nodes, node.files)
return QueryNode(
node.node_name, node.instance_name, node.args, node.sub_nodes, node.files
)

def composite_union(self, args: typing.Union[RootCompositeArgsFnInput, PlaceholderArgs], select: RootCompositeUnionFnOutputSelections) -> QueryNode[RootCompositeUnionFnOutput]:
def composite_union(
self,
args: typing.Union[RootCompositeArgsFnInput, PlaceholderArgs],
select: RootCompositeUnionFnOutputSelections,
) -> QueryNode[RootCompositeUnionFnOutput]:
node = selection_to_nodes(
{"compositeUnion": (args, select)},
{"compositeUnion": NodeDescs.RootCompositeUnionFn},
"$q"
{"compositeUnion": (args, select)},
{"compositeUnion": NodeDescs.RootCompositeUnionFn},
"$q",
)[0]
return QueryNode(node.node_name, node.instance_name, node.args, node.sub_nodes, node.files)
return QueryNode(
node.node_name, node.instance_name, node.args, node.sub_nodes, node.files
)

def mixed_union(self, args: typing.Union[RootCompositeArgsFnInput, PlaceholderArgs], select: RootMixedUnionFnOutputSelections) -> QueryNode[RootMixedUnionFnOutput]:
def mixed_union(
self,
args: typing.Union[RootCompositeArgsFnInput, PlaceholderArgs],
select: RootMixedUnionFnOutputSelections,
) -> QueryNode[RootMixedUnionFnOutput]:
node = selection_to_nodes(
{"mixedUnion": (args, select)},
{"mixedUnion": NodeDescs.RootMixedUnionFn},
"$q"
{"mixedUnion": (args, select)},
{"mixedUnion": NodeDescs.RootMixedUnionFn},
"$q",
)[0]
return QueryNode(node.node_name, node.instance_name, node.args, node.sub_nodes, node.files)
return QueryNode(
node.node_name, node.instance_name, node.args, node.sub_nodes, node.files
)
1 change: 1 addition & 0 deletions tools/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
!src/metagen/Cargo.toml
!src/metagen/src/fdk_rust/static/Cargo.toml
!src/metagen/src/client_rs/static/Cargo.toml
!src/metagen-client-rs/Cargo.toml
!src/mt_deno
!src/pyrt_wit_wire
!src/substantial/
Expand Down

0 comments on commit cd7db98

Please sign in to comment.