-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen.ts
44 lines (40 loc) · 1.25 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
import type { CodegenConfig } from '@graphql-codegen/cli';
import { loadEnvConfig } from '@next/env';
// if you're using Next.js
loadEnvConfig(process.cwd());
const config: CodegenConfig = {
overwrite: true,
generates: {
'src/generated/storyblok.graphql': {
schema: {
'https://gapi.storyblok.com/v1/api': {
headers: {
token: process.env.STORYBLOK_API_TOKEN!,
version: process.env.NODE_ENV === 'production' ? 'published' : 'draft',
},
},
},
plugins: ['schema-ast'],
},
'src/generated/storyblokSdk.ts': {
documents: ['src/graphql/**/*.graphql'],
schema: {
'https://gapi.storyblok.com/v1/api': {
headers: {
token: process.env.STORYBLOK_API_TOKEN!,
version: process.env.NODE_ENV === 'production' ? 'published' : 'draft',
},
},
},
plugins: ['typescript', 'typescript-operations', 'typescript-graphql-request'],
config: {
// all fields in the schema are optional
// but we don't want to check for fields like `slug`
// so, all the validation lies on the shoulders of devs
avoidOptionals: true,
maybeValue: 'T',
},
},
},
};
export default config;