-
Notifications
You must be signed in to change notification settings - Fork 128
/
graphql.config.ts
82 lines (81 loc) · 3.38 KB
/
graphql.config.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
function projectFactory(name: string, schemaName: string, project: string = 'app') {
return {
schema: `./packages/${project}/src/cli/api/graphql/${name}/${schemaName}`,
documents: [`./packages/${project}/src/cli/api/graphql/${name}/queries/**/*.graphql`,`./packages/${project}/src/cli/api/graphql/${name}/mutations/**/*.graphql`],
extensions: {
codegen: {
generates: {
[`./packages/${project}/src/cli/api/graphql/${name}/generated/types.d.ts`]: {
plugins: [
{'graphql-codegen-typescript-operation-types': {enumsAsTypes: true, useTypeImports: true}},
{
add: {
content:
"/* eslint-disable @typescript-eslint/consistent-type-definitions, @typescript-eslint/naming-convention, @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any, tsdoc/syntax, @typescript-eslint/no-duplicate-type-constituents */\nimport {JsonMapType} from '@shopify/cli-kit/node/toml'",
},
},
],
config: {
omitObjectTypes: true,
scalars: {
GlobalID: 'string',
PropertyId: 'string',
PropertyPublicID: 'string',
JSON: {input: 'JsonMapType | string', output: 'JsonMapType'},
URL: 'string',
},
},
},
[`./packages/${project}/src/cli/api/graphql/${name}/generated/`]: {
preset: 'near-operation-file',
plugins: [
{
add: {
content:
"/* eslint-disable @typescript-eslint/consistent-type-definitions, @typescript-eslint/naming-convention, @typescript-eslint/ban-types, @typescript-eslint/no-duplicate-type-constituents */\nimport {JsonMapType} from '@shopify/cli-kit/node/toml'",
},
},
{
'typescript-operations': {
preResolveTypes: true,
skipTypename: true,
useTypeImports: true,
onlyOperationTypes: true,
scalars: {
GlobalID: 'string',
PropertyId: 'string',
PropertyPublicID: 'string',
JSON: {input: 'JsonMapType | string', output: 'JsonMapType'},
URL: 'string',
},
},
},
{
'typed-document-node': {
addTypenameToSelectionSets: true,
},
},
],
presetConfig: {
extension: '.ts',
typesPath: './types.js',
baseTypesPath: './types.js',
folder: '../generated',
useTypeImports: true,
},
},
},
},
},
}
}
export default {
projects: {
partners: projectFactory('partners', 'cli_schema.graphql'),
businessPlatformDestinations: projectFactory('business-platform-destinations', 'destinations_schema.graphql'),
businessPlatformOrganizations: projectFactory('business-platform-organizations', 'organizations_schema.graphql'),
appDev: projectFactory('app-dev', 'app_dev_schema.graphql'),
appManagement: projectFactory('app-management', 'app_management_schema.graphql'),
admin: projectFactory('admin', 'admin_schema.graphql', 'cli-kit'),
},
}