diff --git a/Cargo.lock b/Cargo.lock index 0880f02b1..ee9d650da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10542,27 +10542,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "sample_client" -version = "0.5.0-rc.9" -dependencies = [ - "metagen-client", - "serde", - "serde_json", - "tokio", -] - -[[package]] -name = "sample_client_upload" -version = "0.5.0-rc.9" -dependencies = [ - "metagen-client", - "serde", - "serde_json", - "tokio", - "tokio-util 0.7.11", -] - [[package]] name = "saturating" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index c596d4dd8..67dc9c74e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", ] diff --git a/src/metagen-client-rs/Cargo.toml b/src/metagen-client-rs/Cargo.toml index d920a31de..456e93c40 100644 --- a/src/metagen-client-rs/Cargo.toml +++ b/src/metagen-client-rs/Cargo.toml @@ -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" diff --git a/tests/metagen/typegraphs/sample/py/client.py b/tests/metagen/typegraphs/sample/py/client.py index c1d09cedf..17e933d59 100644 --- a/tests/metagen/typegraphs/sample/py/client.py +++ b/tests/metagen/typegraphs/sample/py/client.py @@ -809,7 +809,7 @@ class NodeDescs: @staticmethod def scalar(): return NodeMeta() - + @staticmethod def Post(): return NodeMeta( @@ -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 @@ -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 + ) diff --git a/tools/Dockerfile.dockerignore b/tools/Dockerfile.dockerignore index 009d0d863..9fe8dd963 100644 --- a/tools/Dockerfile.dockerignore +++ b/tools/Dockerfile.dockerignore @@ -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/