File tree Expand file tree Collapse file tree 3 files changed +73
-15
lines changed Expand file tree Collapse file tree 3 files changed +73
-15
lines changed Original file line number Diff line number Diff line change
1
+ from typegraph .gen .exports .core import (
2
+ ArtifactResolutionConfig ,
3
+ MigrationAction ,
4
+ MigrationConfig ,
5
+ )
6
+ from typegraph .graph .shared_types import BasicAuth
7
+ from typegraph .graph .tg_deploy import TypegraphDeployParams , tg_deploy
1
8
from typegraph .graph .typegraph import Graph
2
9
from typegraph .policy import Policy
3
10
from typegraph .runtimes .wasmedge import WasmEdgeRuntime
@@ -18,3 +25,24 @@ def wasmedge(g: Graph):
18
25
func = "add" ,
19
26
).with_policy (pub ),
20
27
)
28
+
29
+
30
+ PORT = 7698
31
+ gate = f"http://localhost:{ PORT } "
32
+ auth = BasicAuth ("admin" , "password" )
33
+
34
+ wasmedge_tg = wasmedge ()
35
+ serialized , typegate = tg_deploy (
36
+ wasmedge_tg ,
37
+ TypegraphDeployParams (
38
+ base_url = gate ,
39
+ artifacts_config = ArtifactResolutionConfig (
40
+ prisma_migration = MigrationConfig (
41
+ migration_dir = "prisma-migrations" ,
42
+ global_action = MigrationAction (reset = False , create = True ),
43
+ )
44
+ ),
45
+ ),
46
+ )
47
+
48
+ print (serialized )
Original file line number Diff line number Diff line change @@ -5,27 +5,34 @@ import { BasicAuth, tgDeploy } from "@typegraph/sdk/tg_deploy.js";
5
5
import { gql , Meta } from "../../utils/mod.ts" ;
6
6
import { testDir } from "test-utils/dir.ts" ;
7
7
import { tg } from "./wasmedge.ts" ;
8
+ import { SDKLangugage } from "test-utils/test.ts" ;
8
9
9
10
const port = 7698 ;
10
11
const gate = `http://localhost:${ port } ` ;
11
12
const cwdDir = testDir ;
12
13
const auth = new BasicAuth ( "admin" , "password" ) ;
13
14
14
- // Meta.test("WasmEdge runtime", async (t) => {
15
- // const e = await t.engine("runtimes/wasmedge/wasmedge.py", {}, { port });
16
-
17
- // await t.should("works", async () => {
18
- // await gql`
19
- // query {
20
- // test(a: 1, b: 2)
21
- // }
22
- // `
23
- // .expectData({
24
- // test: 3,
25
- // })
26
- // .on(e);
27
- // });
28
- // }, { port: port });
15
+ Meta . test ( "WasmEdge runtime" , async ( t ) => {
16
+ await t . should ( "works" , async ( ) => {
17
+ const serialized = await t . serializeTypegraphFromShell (
18
+ "runtimes/wasmedge/wasmedge.py" ,
19
+ SDKLangugage . Python ,
20
+ ) ;
21
+
22
+ const engine = await t . engineFromDeployed ( serialized ) ;
23
+
24
+ await gql `
25
+ query {
26
+ test(a: 1, b: 2)
27
+ }
28
+ `
29
+ . expectData ( {
30
+ test : 3 ,
31
+ } )
32
+ . on ( engine ) ;
33
+ await engine . terminate ( ) ;
34
+ } ) ;
35
+ } , { port : port } ) ;
29
36
30
37
Meta . test ( "WasmEdge Runtime typescript sdk" , async ( metaTest ) => {
31
38
await metaTest . should ( "work after deploying artifact" , async ( ) => {
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ export interface ParseOptions {
31
31
pretty ?: boolean ;
32
32
}
33
33
34
+ export enum SDKLangugage {
35
+ Python = "python3" ,
36
+ TypeScript = "deno" ,
37
+ }
38
+
34
39
function serve ( typegate : Typegate , port : number ) : ( ) => void {
35
40
const server = Deno . serve ( { port } , ( req ) => {
36
41
return typegate . handle ( req , {
@@ -157,6 +162,24 @@ export class MetaTest {
157
162
return engine ;
158
163
}
159
164
165
+ async serializeTypegraphFromShell (
166
+ path : string ,
167
+ lang : SDKLangugage ,
168
+ ) : Promise < string > {
169
+ // run self deployed typegraph
170
+ const { stderr, stdout } = await this . shell ( [ lang . toString ( ) , path ] ) ;
171
+
172
+ if ( stderr . length > 0 ) {
173
+ throw new Error ( `${ stderr } ` ) ;
174
+ }
175
+
176
+ if ( stdout . length === 0 ) {
177
+ throw new Error ( "No typegraph" ) ;
178
+ }
179
+
180
+ return stdout ;
181
+ }
182
+
160
183
async unregister ( engine : QueryEngine ) {
161
184
await Promise . all (
162
185
this . register
You can’t perform that action at this time.
0 commit comments