Skip to content

Commit 18c410e

Browse files
committed
feat: add factory class
1 parent 2947f95 commit 18c410e

File tree

3 files changed

+87
-0
lines changed
  • packages
    • schema/bind/src/bindings/wasm-as/templates/imported/query-type
    • test-cases/cases/bind/sanity/output/wasm-as
      • mutation/imported/TestImport_Mutation
      • query/imported/TestImport_Query

3 files changed

+87
-0
lines changed

packages/schema/bind/src/bindings/wasm-as/templates/imported/query-type/index-ts.mustache

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,29 @@ export class {{type}} {
3939
{{/last}}
4040
{{/methods}}
4141
}
42+
43+
export class {{type}}_Factory {
44+
45+
public uri: string;
46+
47+
constructor(uri: string) {
48+
this.uri = uri;
49+
}
50+
51+
{{#methods}}
52+
public {{name}}(input: Input_{{name}}): {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}} {
53+
const args = serialize{{name}}Args(input);
54+
const result = w3_subinvoke(
55+
this.uri,
56+
"{{type}}",
57+
"{{name}}",
58+
args
59+
);
60+
return deserialize{{name}}Result(result);
61+
}
62+
{{^last}}
63+
64+
{{/last}}
65+
{{/methods}}
66+
}
4267
{{/__commonImport}}

packages/test-cases/cases/bind/sanity/output/wasm-as/mutation/imported/TestImport_Mutation/index.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,34 @@ export class TestImport_Mutation {
4040
return deserializeanotherMethodResult(result);
4141
}
4242
}
43+
44+
export class TestImport_Mutation_Factory {
45+
46+
public uri: string;
47+
48+
constructor(uri: string) {
49+
this.uri = uri;
50+
}
51+
52+
public importedMethod(input: Input_importedMethod): Types.TestImport_Object | null {
53+
const args = serializeimportedMethodArgs(input);
54+
const result = w3_subinvoke(
55+
this.uri,
56+
"mutation",
57+
"importedMethod",
58+
args
59+
);
60+
return deserializeimportedMethodResult(result);
61+
}
62+
63+
public anotherMethod(input: Input_anotherMethod): i32 {
64+
const args = serializeanotherMethodArgs(input);
65+
const result = w3_subinvoke(
66+
this.uri,
67+
"mutation",
68+
"anotherMethod",
69+
args
70+
);
71+
return deserializeanotherMethodResult(result);
72+
}
73+
}

packages/test-cases/cases/bind/sanity/output/wasm-as/query/imported/TestImport_Query/index.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,34 @@ export class TestImport_Query {
4040
return deserializeanotherMethodResult(result);
4141
}
4242
}
43+
44+
export class TestImport_Query_Factory {
45+
46+
public uri: string;
47+
48+
constructor(uri: string) {
49+
this.uri = uri;
50+
}
51+
52+
public importedMethod(input: Input_importedMethod): Types.TestImport_Object | null {
53+
const args = serializeimportedMethodArgs(input);
54+
const result = w3_subinvoke(
55+
this.uri,
56+
"query",
57+
"importedMethod",
58+
args
59+
);
60+
return deserializeimportedMethodResult(result);
61+
}
62+
63+
public anotherMethod(input: Input_anotherMethod): i32 {
64+
const args = serializeanotherMethodArgs(input);
65+
const result = w3_subinvoke(
66+
this.uri,
67+
"query",
68+
"anotherMethod",
69+
args
70+
);
71+
return deserializeanotherMethodResult(result);
72+
}
73+
}

0 commit comments

Comments
 (0)