-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcodegen.takeshape.config.ts
45 lines (40 loc) · 1.25 KB
/
codegen.takeshape.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 takeshapeApiUrl = process.env.NEXT_PUBLIC_BRANCH_TAKESHAPE_API_URL ?? process.env.NEXT_PUBLIC_TAKESHAPE_API_URL;
const takeshapeAnonymousApiKey = process.env.NEXT_PUBLIC_TAKESHAPE_ANONYMOUS_API_KEY;
assert(takeshapeApiUrl, 'NEXT_PUBLIC_TAKESHAPE_API_URL is required');
assert(takeshapeAnonymousApiKey, 'NEXT_PUBLIC_TAKESHAPE_ANONYMOUS_API_KEY is required');
const config: CodegenConfig = {
overwrite: true,
documents: ['src/**/queries.ts', 'src/**/queries.takeshape.ts'],
schema: {
[takeshapeApiUrl]: {
headers: {
Authorization: `Bearer ${takeshapeAnonymousApiKey}`
}
}
},
generates: {
'./src/types/takeshape.ts': {
plugins: ['typescript', 'typescript-operations'],
config: {
omitOperationSuffix: true,
operationResultSuffix: 'Response',
enumsAsTypes: true,
avoidOptionals: {
field: true,
inputValue: false,
object: false,
defaultValue: false
},
scalars: {
DateTime: 'string'
}
}
}
}
};
export default config;