-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen.ts
110 lines (107 loc) · 3.04 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { CodegenConfig } from '@graphql-codegen/cli';
import { TypeScriptTypedDocumentNodesConfig } from '@graphql-codegen/typed-document-node';
import { TypeScriptPluginConfig } from '@graphql-codegen/typescript';
import { TypeScriptDocumentsPluginConfig } from '@graphql-codegen/typescript-operations';
import { TypeScriptResolversPluginConfig } from '@graphql-codegen/typescript-resolvers';
const typescriptPluginConfig: TypeScriptPluginConfig = {
useImplementingTypes: true,
defaultScalarType: 'unknown',
nonOptionalTypename: true,
scalars: {
DateTime: 'number',
UploadItem: 'ClientTypes.UploadItem'
},
strictScalars: true,
useTypeImports: true,
avoidOptionals: {
field: true,
object: false,
inputValue: false,
resolvers: false,
defaultValue: false
}
};
const config: CodegenConfig = {
schema: {
'https://raw.githubusercontent.com/Zextras/carbonio-files-ce/develop/core/src/main/resources/api/schema.graphql':
{
headers: {
Cookie: ''
}
}
},
generates: {
'src/carbonio-files-ui-common/graphql/schema.graphql': {
plugins: [
'schema-ast',
{
add: {
content: ['" THIS FILE IS AUTOGENERATED BY GRAPHQL-CODEGEN. DO NOT EDIT! "']
}
}
]
},
'src/carbonio-files-ui-common/types/graphql/types.ts': {
schema: 'src/carbonio-files-ui-common/graphql/client-schema.graphql',
documents: ['src/**/*.graphql'],
plugins: [
'typescript',
'typescript-operations',
'typed-document-node',
{
add: {
content: [
'// THIS FILE IS AUTOGENERATED BY GRAPHQL-CODEGEN. DO NOT EDIT!',
"import * as ClientTypes from './client-types'"
]
}
}
],
config: {
...typescriptPluginConfig,
exportFragmentSpreadSubTypes: true,
mergeFragmentTypes: true,
skipTypeNameForRoot: true
} satisfies TypeScriptPluginConfig &
TypeScriptDocumentsPluginConfig &
TypeScriptTypedDocumentNodesConfig
},
'src/carbonio-files-ui-common/types/graphql/possible-types.ts': {
schema: 'src/carbonio-files-ui-common/graphql/client-schema.graphql',
documents: ['src/**/*.graphql'],
plugins: [
'fragment-matcher',
{ add: { content: '// THIS FILE IS AUTOGENERATED BY GRAPHQL-CODEGEN. DO NOT EDIT!' } }
]
},
'src/carbonio-files-ui-common/types/graphql/resolvers-types.ts': {
// exclude client documents from resolvers
documents: ['src/**/(queries|mutations|fragments)/*.graphql'],
plugins: [
'typescript',
'typescript-resolvers',
{
add: {
content: [
'/* eslint-disable @typescript-eslint/ban-types,@typescript-eslint/no-explicit-any */',
'// THIS FILE IS AUTOGENERATED BY GRAPHQL-CODEGEN. DO NOT EDIT!'
]
}
}
],
config: {
...typescriptPluginConfig
} satisfies TypeScriptPluginConfig & TypeScriptResolversPluginConfig
}
},
hooks: {
afterAllFileWrite:
'eslint --fix --resolve-plugins-relative-to node_modules/@zextras/carbonio-ui-configs'
}
};
export default config;