-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen.ts
85 lines (82 loc) · 1.97 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* eslint-disable import/no-extraneous-dependencies */
import { CodegenConfig } from '@graphql-codegen/cli';
import 'dotenv/config';
const bearerToken = process.env.SGG_TOKEN;
// A bearer token with Start.gg must be provided to be able to introspect anything.
// I don't want to accidentally commit mine. :)
if (!bearerToken) {
throw new Error('Bearer token must be provided.');
}
const config: CodegenConfig = {
schema: [
{
'https://api.start.gg/gql/alpha': {
headers: {
Authorization: 'Bearer ' + process.env.SGG_TOKEN
}
}
}
],
documents: ['src/queries/*.graphql'],
generates: {
'./generated/types.d.ts': {
plugins: [
{
add: {
placement: 'prepend',
content: '/* This file is auto-generated. Do not edit. */ \ndeclare namespace StartGG {'
}
},
{
add: {
placement: 'append',
content: '}'
}
},
'typescript'
],
config: {
preResolveTypes: true,
enumsAsTypes: true,
allowEnumStringTypes: true,
scalars: {
JSON: '{ [key: string]: any }',
Timestamp: 'number'
},
noExport: true
}
},
'./generated/sdk.ts': {
plugins: [
{
add: {
content: '/* This file is auto-generated. Do not edit. */'
}
},
'typescript',
'typescript-operations',
'typescript-graphql-request'
],
config: {
preResolveTypes: true,
enumsAsTypes: true,
allowEnumStringTypes: true,
scalars: {
JSON: '{ [key: string]: any }',
Timestamp: 'number'
},
rawRequest: true,
dedupeOperationSuffix: true
}
},
'./generated/schema.json': {
plugins: ['introspection'],
config: {
minify: true
}
}
},
ignoreNoDocuments: false,
verbose: true
};
export default config;