-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.ts
More file actions
67 lines (65 loc) · 1.86 KB
/
Copy pathcodegen.ts
File metadata and controls
67 lines (65 loc) · 1.86 KB
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
import type { CodegenConfig } from '@graphql-codegen/cli';
import { addTypenameSelectionDocumentTransform } from '@graphql-codegen/client-preset';
import { printSchema } from 'graphql';
import { schema } from '~/graphql/schema';
const config: CodegenConfig = {
schema: printSchema(schema),
documents: ['src/**/*.tsx', 'src/**/*.ts'],
generates: {
'./src/app/graphql/generated/': {
preset: 'client',
presetConfig: {
persistedDocuments: true,
fragmentMasking: { unmaskFunctionName: 'getFragment' },
},
documentTransforms: [addTypenameSelectionDocumentTransform],
plugins: [],
config: {
nonOptionalTypename: true,
dedupeFragments: true,
enumType: 'native',
scalars: {
// ISOString (i.e. "2024-05-13T15:58:12.957Z")
DateTime: 'string',
Date: 'string',
},
},
},
/**
* Starting with @graphql-codegen/cli@^7
*
* - The generated 'graphql.ts' no longer includes all base types
* - So we generate them explicitly, and at the same time, we need to sync the
* type configuration with the client-preset
*/
'./src/app/graphql/generated/types.ts': {
plugins: [
'typescript',
{
add: {
content: "export type * from './graphql'",
},
},
],
config: {
nonOptionalTypename: true,
enumsAsTypes: false,
scalars: {
// ISOString (i.e. "2024-05-13T15:58:12.957Z")
DateTime: 'string',
Date: 'string',
},
},
},
'./src/app/graphql/generated/type-policies.ts': {
plugins: ['typescript-apollo-client-helpers'],
},
'./src/app/graphql/generated/schema.graphql': {
plugins: ['schema-ast'],
config: {
includeDirectives: true,
},
},
},
};
export default config;