forked from JSConfCL/tickets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen.ts
58 lines (56 loc) · 1.53 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
import type { CodegenConfig } from "@graphql-codegen/cli";
import defaultConfig from "./graphql.config";
const noTypeCheckingPlugin = {
add: {
content: [
"/* eslint-disable */",
"/* @ts-nocheck */",
"/* prettier-ignore */",
"/* This file is automatically generated. Please do not modify it manually. */",
],
},
};
const config = {
...defaultConfig,
ignoreNoDocuments: true,
generates: {
"src/api/gql/": {
preset: "client",
plugins: [noTypeCheckingPlugin],
config: {
useTypeImports: true,
skipTypename: true,
avoidOptionals: true,
nonOptionalTypename: false,
// Lamentablemente, code-gen establece "any" como predeterminado, cuando no tiene un
// tipo para un "scalar". Esta opción nos obliga a definir un tipo cada vez que
// queremos usar un escalar sin tipo.
defaultScalarType: "unknown",
scalars: {
Date: "string",
DateTime: "string",
},
},
},
"./src/api/gql/schema.gql": {
plugins: ["schema-ast"],
},
"src/": {
preset: "near-operation-file",
presetConfig: {
extension: ".generated.tsx",
baseTypesPath: "api/gql/graphql.ts",
},
plugins: [
"typescript-operations",
"typescript-react-apollo",
// "./codegen-apollo-hooks.js",
noTypeCheckingPlugin,
],
config: {
apolloReactHooksImportFrom: "@/api/ApolloHooks",
},
},
},
} satisfies CodegenConfig;
export default config;