-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.ts
More file actions
28 lines (25 loc) · 830 Bytes
/
codegen.ts
File metadata and controls
28 lines (25 loc) · 830 Bytes
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
import { CodegenConfig } from '@graphql-codegen/cli';
import * as dotenv from 'dotenv';
dotenv.config();
const apiKey = process.env.NEXT_PUBLIC_CONTENTSTACK_API_KEY!;
const environment = process.env.NEXT_PUBLIC_CONTENTSTACK_ENVIRONMENT!;
const region = process.env.NEXT_PUBLIC_CONTENTSTACK_REGION!;
const baseURL = region === 'EU' ? 'eu-graphql.contentstack.com' : 'graphql.contentstack.com'
const accessToken = process.env.NEXT_PUBLIC_CONTENTSTACK_DELIVERY_TOKEN!;
const config: CodegenConfig = {
schema: {
[`https://${baseURL}/stacks/${apiKey}?environment=${environment}`]: {
headers: {
access_token: accessToken,
},
},
},
documents: ['./**/*.tsx', './**/*.ts', '!src/gql/**/*'],
generates: {
'./gql/': {
preset: 'client',
plugins: [],
},
},
};
export default config;