-
Notifications
You must be signed in to change notification settings - Fork 0
/
.graphqlrc.ts
71 lines (67 loc) · 2.05 KB
/
.graphqlrc.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
import 'dotenv/config';
import { datocmsEnvironment } from './datocms-environment';
const outputFilename = 'src/lib/datocms/types.ts';
console.log(`Saving generated types for DatoCMS (environment: '${datocmsEnvironment}') to '${outputFilename}'.`);
/**
* @link https://graphql-config.com/introduction
*/
module.exports = {
schema: {
'https://graphql.datocms.com': {
headers: {
Authorization: process.env.DATOCMS_READONLY_API_TOKEN,
'X-Environment': datocmsEnvironment,
'X-Exclude-Invalid': 'true',
},
},
},
documents: 'src/**/*.graphql',
extensions: {
codegen: {
overwrite: true,
generates: {
[outputFilename]: {
plugins: [
'typescript',
'typescript-operations',
'@graphql-codegen/typescript-document-nodes',
],
/**
* scalar config borrowed from DatoCMS team:
* @see https://github.com/Tonel/typescript-type-generation-graphql-example/blob/2d43584b1d75c9086c4ddd594a6b2401a29b0055/graphql.config.yml#L11-L23
*/
config: {
dedupeFragments: true,
strictScalars: true,
scalars: {
BooleanType: 'boolean',
CustomData: 'Record<string, unknown>',
Date: 'string',
DateTime: 'string',
FloatType: 'number',
IntType: 'number',
ItemId: 'string',
JsonField: 'unknown',
MetaTagAttributes: 'Record<string, string>',
UploadId: 'string',
},
// namingConvention: {
// enumValues: './pascalCaseWithUnderscores',
// },
},
// 'src/lib/datocms.schema.json': {
// plugins: [
// 'introspection',
// ],
// config: {
// dedupeFragments: true,
// pureMagicComment: true,
// exportFragmentSpreadSubTypes: true,
// namingConvention: 'keep',
// },
// },
},
},
},
},
};