-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathcodegen.ts
More file actions
50 lines (46 loc) · 1.47 KB
/
codegen.ts
File metadata and controls
50 lines (46 loc) · 1.47 KB
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
import type { CodegenConfig } from '@graphql-codegen/cli'
import { adminApiCustomScalars, storefrontApiCustomScalars } from './codegen.helpers'
import { adminApiSchema, storefrontApiSchema } from './codegen.schema'
if (!storefrontApiSchema) {
throw new Error(
'Missing required Shopify environment variables for Storefront API Codegen support.',
)
}
const config: CodegenConfig = {
overwrite: true,
generates: {
// Admin
...(adminApiSchema && {
'./types/shopify-admin.d.ts': {
schema: adminApiSchema,
documents: './modules/shopify/runtime/resources/graphql/admin/**/*.ts',
plugins: ['typescript', 'typescript-operations'],
config: {
skipTypename: true,
useTypeImports: true,
defaultScalarType: 'unknown',
useImplementingTypes: true,
enumsAsTypes: true,
scalars: adminApiCustomScalars,
},
},
}),
// Storefront
...(storefrontApiSchema && {
'./types/shopify-storefront.d.ts': {
schema: storefrontApiSchema,
documents: './modules/shopify/runtime/resources/graphql/storefront/**/*.ts',
plugins: ['typescript', 'typescript-operations'],
config: {
skipTypename: true,
useTypeImports: true,
defaultScalarType: 'unknown',
useImplementingTypes: true,
enumsAsTypes: true,
scalars: storefrontApiCustomScalars,
},
},
}),
},
}
export default config