forked from Shopify/hydrogen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.ts
58 lines (56 loc) · 1.91 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 {CodegenConfig} from '@graphql-codegen/cli';
// Because this file is processed only in TypeScript, we can make one exception for not using an extension here.
// eslint-disable-next-line import/extensions
import {storefrontApiCustomScalars} from './src/codegen.helpers';
const config: CodegenConfig = {
overwrite: true,
schema: {
'https://hydrogen-preview.myshopify.com/api/2023-01/graphql.json': {
headers: {
'X-Shopify-Storefront-Access-Token': '3b580e70970c4528da70c98e097c2fa0',
'content-type': 'application/json',
},
},
},
generates: {
// The generated base types
'src/storefront-api-types.d.ts': {
plugins: [
{
add: {
content: `
/**
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT
* Based on Storefront API 2023-01
* If changes need to happen to the types defined in this file, then generally the Storefront API needs to update. After it's updated, you can run \`npm run graphql-types\`.
* Except custom Scalars, which are defined in the \`codegen.ts\` file
*/
/* eslint-disable */`,
},
},
{
typescript: {
useTypeImports: true,
// If a default type for a scalar isn't set, then instead of 'any' we set to 'unknown' for better type safety.
defaultScalarType: 'unknown',
useImplementingTypes: true,
enumsAsTypes: true,
// Define how the Storefront API's custom scalars map to TypeScript types
scalars: storefrontApiCustomScalars,
},
},
],
},
// The schema file, which is the local representation of the GraphQL endpoint
'./storefront.schema.json': {
plugins: [
{
introspection: {
minify: true,
},
},
],
},
},
};
export default config;