-
Notifications
You must be signed in to change notification settings - Fork 7
/
codegen.storefront.config.ts
45 lines (40 loc) · 1.2 KB
/
codegen.storefront.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
import { CodegenConfig } from '@graphql-codegen/cli';
import dotenv from 'dotenv';
import assert from 'node:assert';
dotenv.config({ path: `.env` });
dotenv.config({ path: `.env.local` });
const shopifyStorefrontUrl = process.env.NEXT_PUBLIC_SHOPIFY_STOREFRONT_URL;
const shopifyStorefrontToken = process.env.NEXT_PUBLIC_SHOPIFY_STOREFRONT_TOKEN;
assert(shopifyStorefrontUrl, 'NEXT_PUBLIC_SHOPIFY_STOREFRONT_URL is required');
assert(shopifyStorefrontToken, 'NEXT_PUBLIC_SHOPIFY_STOREFRONT_TOKEN is required');
const config: CodegenConfig = {
overwrite: true,
documents: 'src/**/queries.storefront.ts',
schema: {
[shopifyStorefrontUrl]: {
headers: {
['X-Shopify-Storefront-Access-Token']: shopifyStorefrontToken
}
}
},
generates: {
'./src/types/storefront.ts': {
plugins: ['typescript', 'typescript-operations'],
config: {
omitOperationSuffix: true,
operationResultSuffix: 'Response',
enumsAsTypes: true,
avoidOptionals: {
field: true,
inputValue: false,
object: true,
defaultValue: true
},
scalars: {
DateTime: 'string'
}
}
}
}
};
export default config;