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!: JSON RPC based typegraph #877

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
eb2db29
update: replace wit with codegen interface
luckasRanarison Oct 25, 2024
c3e62f9
wip: dummy server & client sdk rewrite
luckasRanarison Oct 28, 2024
a3077a7
fixup: cleanup
luckasRanarison Oct 28, 2024
fe4b9f1
wip: fix python & try testing
luckasRanarison Oct 29, 2024
93c8226
fix: dev mode & test typegraph parsing
luckasRanarison Nov 4, 2024
752bafe
Merge branch 'main' into feat/typegraph-ng
luckasRanarison Nov 4, 2024
cc03068
fix: several fixes
luckasRanarison Nov 4, 2024
332cd39
wip: fix tests
luckasRanarison Nov 4, 2024
30fc9b9
fix: ghjk tg-build & codegen deno
luckasRanarison Nov 5, 2024
a2c02cb
fix: remove wasm related ops
luckasRanarison Nov 5, 2024
70375bb
fix: TS client
luckasRanarison Nov 5, 2024
76a2064
fix: bad mappings
luckasRanarison Nov 5, 2024
4de7198
fix: wasm tests
luckasRanarison Nov 5, 2024
dc7c676
fix: tg-build
luckasRanarison Nov 6, 2024
e3bc708
fix: node support
luckasRanarison Nov 6, 2024
5129994
fix: cli stuff
luckasRanarison Nov 6, 2024
530446d
fix: fs operations & python lockfile
luckasRanarison Nov 6, 2024
122ca73
fix: python sync test
luckasRanarison Nov 6, 2024
fd3942f
wip: temporary fixes
luckasRanarison Nov 11, 2024
ad4070b
fix prisma_test.ts, fix pre-commit
Natoandro Nov 12, 2024
0a1626f
fix other tests
Natoandro Nov 12, 2024
89a91f9
wip: more fixes
luckasRanarison Nov 12, 2024
f9d32d0
fix: snapshot test
luckasRanarison Nov 12, 2024
96d3080
Merge branch 'main' into feat/typegraph-ng
luckasRanarison Nov 13, 2024
d9cacb2
fix: build & merge conflicts
luckasRanarison Nov 13, 2024
0a709c2
fixup: missing import
luckasRanarison Nov 13, 2024
87b6774
fix: jsonrpc prefix
luckasRanarison Nov 13, 2024
c72ddaa
lint (pre-commit)
Natoandro Nov 14, 2024
1f9f159
remove conflicting migrations
Natoandro Nov 14, 2024
cfb0745
fix: merge conflicts
luckasRanarison Nov 14, 2024
b54bdf1
fix: build & some tests
luckasRanarison Nov 14, 2024
39f7b3a
fix: validation test
luckasRanarison Nov 15, 2024
b6f7c39
fix: deno.lock
luckasRanarison Nov 15, 2024
90e42de
Merge branch 'main' into feat/typegraph-ng
luckasRanarison Nov 16, 2024
323571a
fix: some fixes & cleanup
luckasRanarison Nov 16, 2024
045f4a1
fix: additional fixes
luckasRanarison Nov 16, 2024
958a483
fix: metagen & workflow
luckasRanarison Nov 17, 2024
af25ea4
fix: pre-commit
luckasRanarison Nov 17, 2024
63afdea
fix: docker build
luckasRanarison Nov 18, 2024
055bbcd
fix: some parts
luckasRanarison Nov 20, 2024
af5a9b2
fix: dockerfile
luckasRanarison Nov 20, 2024
95e5d45
Merge branch 'main' into feat/typegraph-ng
luckasRanarison Nov 25, 2024
aea1bca
fix: remove logger
luckasRanarison Nov 25, 2024
3ac927e
Merge branch 'main' into feat/typegraph-ng
luckasRanarison Dec 3, 2024
fbb7287
fix: metagen test
luckasRanarison Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: metagen & workflow
[skip ci]
  • Loading branch information
luckasRanarison committed Nov 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 958a48391c1e2cc4aa4767663259ef3f2fe3ff76
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -293,6 +293,7 @@ jobs:
ghjk x dev update --cache-only

ghjk x test-rust
ghjk x test-codegen

ghjk x test-e2e -- --coverage=coverage

2 changes: 1 addition & 1 deletion src/meta-cli/src/typegraph/rpc/mod.rs
Original file line number Diff line number Diff line change
@@ -19,6 +19,6 @@ pub trait RpcDispatch {
pub enum RpcCall {
Aws(aws::RpcCall),
Core(core::RpcCall),
Utils(utils::RpcCall),
Runtimes(runtimes::RpcCall),
Utils(utils::RpcCall),
}
28 changes: 9 additions & 19 deletions src/metagen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -47,7 +47,6 @@ mod utils;
use crate::interlude::*;

pub use config::*;
use futures_concurrency::future::FutureGroup;
pub use shared::FdkTemplate;

pub use fdk_python::DEFAULT_TEMPLATE as FDK_PYTHON_DEFAULT_TEMPLATE;
@@ -216,20 +215,19 @@ impl GeneratorRunner {
}
}

// FIXME: Bring FutureGroup back after multithreading support for typegraph core (MET-755)
pub async fn generate_target(
config: &config::Config,
target_name: &str,
workspace_path: PathBuf,
resolver: impl InputResolver + Send + Sync + Clone + 'static,
) -> anyhow::Result<GeneratorOutput> {
use futures_lite::StreamExt;

let target_conf = config
.targets
.get(target_name)
.with_context(|| format!("target {target_name:?} not found in config"))?;

let mut group = FutureGroup::new();
let mut group = Vec::new();
for config in &target_conf.0 {
let gen_name = &config.generator_name;
let config = config.other.to_owned();
@@ -239,28 +237,20 @@ pub async fn generate_target(
let gen_impl = get_gen_op.exec(&workspace_path, config)?;
let bill = gen_impl.bill_of_inputs();

let mut resolve_group = FutureGroup::new();
let mut resolved = Vec::new();
for (name, order) in bill.into_iter() {
let resolver = resolver.clone();
resolve_group.insert(Box::pin(async move {
anyhow::Ok((name, resolver.resolve(order).await?))
}));
let result = resolver.resolve(order).await?;
resolved.push((name, result));
}

let gen_name: Arc<str> = gen_name[..].into();
group.insert(Box::pin(async move {
let mut inputs = IndexMap::new();
while let Some(res) = resolve_group.next().await {
let (name, input) = res?;
inputs.insert(name, input);
}
let out = gen_impl.generate(inputs)?;
anyhow::Ok((gen_name, out))
}));
let inputs = IndexMap::from_iter(resolved);
let out = gen_impl.generate(inputs)?;
group.push((gen_name, out));
}
let mut out = IndexMap::new();
while let Some(res) = group.next().await {
let (gen_name, files) = res?;
for (gen_name, files) in group.into_iter() {
for (path, buf) in files.0 {
if let Some((src, _)) = out.get(&path) {
anyhow::bail!("generators \"{src}\" and \"{gen_name}\" clashed at \"{path:?}\"");
1 change: 1 addition & 0 deletions src/metagen/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ use crate::{interlude::*, *};

mod fixtures;
pub use fixtures::*;
use futures_concurrency::future::FutureGroup;
use futures_lite::StreamExt as _;

#[derive(Clone)]
2 changes: 1 addition & 1 deletion src/typegraph/core/src/types/sdk/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod aws;
pub mod core;
pub mod utils;
pub mod runtimes;
pub mod utils;
pub use self::core::Error;
5 changes: 4 additions & 1 deletion tests/metagen/typegraphs/identities/py/handlers_types.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ class Ctx:
def gql(self, query: str, variables: str) -> Any:
pass


class Struct:
def repr(self):
return asdict(self)
@@ -211,12 +210,14 @@ class SimpleCycles3(Struct):
FORWARD_REFS["SimpleCycles3"] = SimpleCycles3



def __repr(value: Any):
if isinstance(value, Struct):
return value.repr()
return value



def typed_primitives(user_fn: Callable[[PrimitivesArgs, Ctx], Primitives]):
def exported_wrapper(raw_inp, ctx):
inp: PrimitivesArgs = Struct.new(PrimitivesArgs, raw_inp)
@@ -259,3 +260,5 @@ def exported_wrapper(raw_inp, ctx):
return __repr(out)

return exported_wrapper


1 change: 1 addition & 0 deletions tests/metagen/typegraphs/sample/py/client.py
Original file line number Diff line number Diff line change
@@ -890,3 +890,4 @@ def mixed_union(self, args: typing.Union[RootCompositeArgsFnInput, PlaceholderAr
"$q"
)[0]
return QueryNode(node.node_name, node.instance_name, node.args, node.sub_nodes)

1 change: 1 addition & 0 deletions tests/metagen/typegraphs/sample/rs/client.rs
Original file line number Diff line number Diff line change
@@ -2522,3 +2522,4 @@ impl QueryGraph {
}
}
}

3 changes: 2 additions & 1 deletion tests/metagen/typegraphs/sample/ts/client.ts
Original file line number Diff line number Diff line change
@@ -353,7 +353,7 @@ function convertQueryNodeGql(
: `${node.instanceName}: ${node.nodeName}`;

const args = node.args;
if (args) {
if (args && Object.keys(args).length > 0) {
out = `${out} (${
Object.entries(args)
.map(([key, val]) => {
@@ -951,3 +951,4 @@ export class QueryGraph extends _QueryGraphBase {
return new QueryNode(inner) as QueryNode<RootMixedUnionFnOutput>;
}
}

21 changes: 1 addition & 20 deletions tests/utils/test.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ import {
} from "@metatype/typegate/config.ts";
// until deno supports it...
import { AsyncDisposableStack } from "dispose";
import { Typegraph } from "@metatype/typegate/typegraph/types.ts";
import { metaCli } from "test-utils/meta.ts";
import { $ } from "@david/dax";
import { sleep } from "test-utils/mod.ts";
@@ -200,24 +199,6 @@ export class MetaTest {
await this.typegates.next().removeTypegraph(tgName);
}

async #engineFromTypegraph(
tg: Typegraph,
secrets: Record<string, string>,
): Promise<QueryEngine> {
const { engine, response } = await this.typegate.pushTypegraph(
tg,
secrets,
this.introspection,
);

if (engine == null) {
throw response.failure!;
}

this.addCleanup(() => engine[Symbol.asyncDispose]());
return engine;
}

async engine(path: string, opts: ParseOptions = {}) {
console.log("t.engine", this.port, opts);
const secrets = opts.secrets ?? {};
@@ -253,7 +234,7 @@ export class MetaTest {
}

if (opts.syncMode) {
await sleep(1000);
await sleep(5000);
}

const prefix = opts.prefix ?? "";
2 changes: 1 addition & 1 deletion tools/tasks/test.ts
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ export default {
inherit: "ci",
workingDir: "./src/typegraph/specs/codegen",
async fn($) {
await $`deno task test`;
await $`bash -c "deno task test"`;
},
},
} satisfies Record<string, DenoTaskDefArgs>;