generated from kimyvgy/worker-apollo-server-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcodegen.ts
61 lines (58 loc) · 1.43 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import type { CodegenConfig } from "@graphql-codegen/cli";
const preventLinting = [
"/* eslint-disable */",
"/* @ts-nocheck */",
"/* prettier-ignore */",
"/* This file is automatically generated using `npm run graphql:types` */",
`import type { JsonObject } from "type-fest";`,
``,
];
const codeInjection = {
add: {
content: [...preventLinting],
},
};
const config: CodegenConfig = {
hooks: { afterOneFileWrite: ["prettier --write"] },
ignoreNoDocuments: true,
schema: "./src/generated/schema.gql",
documents: ["./src/**/*.gql"],
generates: {
"src/generated/types.ts": {
plugins: ["typescript", codeInjection],
config: {
scalars: {
Date: "string",
DateTime: "string",
},
},
},
"src/generated/": {
preset: "near-operation-file",
plugins: [
// "typescript",
"typescript-operations",
"typescript-document-nodes",
codeInjection,
],
presetConfig: {
baseTypesPath: "types.ts",
// importTypesNamespace: "SchemaTypes",
extension: ".generated.ts",
},
config: {
scalars: {
Date: "string",
DateTime: "string",
},
avoidOptionals: true,
enumsAsTypes: false,
useTypeImports: true,
strictScalars: true,
defaultScalarType: "unknown",
preResolveTypes: true,
},
},
},
};
export default config;