-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen.ts
37 lines (33 loc) · 1.15 KB
/
codegen.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { codegen } from "@graphql-codegen/core";
import * as typescriptPlugin from "@graphql-codegen/typescript";
import * as typescriptResolversPlugin from "@graphql-codegen/typescript-resolvers";
import { join } from "@std/path";
import { loadSchemaSync } from '@graphql-tools/load';
import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
const schema = loadSchemaSync(join(Deno.cwd(), 'schema.graphql'), {
loaders: [new GraphQLFileLoader()],
});
const outputFile = "./src/graphql.ts";
const output = await codegen({
documents: [],
config: {},
// used by a plugin internally, although the 'typescript' plugin currently
// returns the string output, rather than writing to a file
filename: outputFile,
schema: schema,//parse(printSchema(schema)),
plugins: [
// Each plugin should be an object
{
typescript: {}, // Here you can pass configuration to the plugin
},
{
typescriptResolvers: {},
},
],
pluginMap: {
typescript: typescriptPlugin,
typescriptResolvers: typescriptResolversPlugin,
},
});
await Deno.writeFile(outputFile, new TextEncoder().encode(output));
console.log("Outputs generated!");