generated from contentful/template-marketing-webapp-nextjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.ts
60 lines (57 loc) · 1.53 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
import { CodegenConfig } from '@graphql-codegen/cli';
import { fetchConfig } from './src/lib/fetchConfig';
export const config: CodegenConfig = {
overwrite: true,
ignoreNoDocuments: true,
schema: [
{
[fetchConfig.endpoint]: fetchConfig.params,
},
],
generates: {
'./src/lib/__generated/graphql.schema.json': {
plugins: ['introspection'],
},
'./src/lib/__generated/graphql.schema.graphql': {
plugins: ['schema-ast'],
},
'./src/lib/__generated/graphql.types.ts': {
plugins: ['typescript', 'typescript-operations'],
documents: ['./src/**/*.graphql'],
},
'./src/': {
documents: ['./src/**/*.graphql'],
preset: 'near-operation-file',
presetConfig: {
extension: '.generated.ts',
baseTypesPath: 'lib/__generated/graphql.types.ts',
folder: '__generated',
},
plugins: [
'typescript-operations',
'typescript-react-query',
{
add: {
content: "import { fetchConfig } from '@src/lib/fetchConfig';",
},
},
],
config: {
exposeQueryKeys: true,
exposeFetcher: true,
rawRequest: false,
inlineFragmentTypes: 'combine',
skipTypename: false,
exportFragmentSpreadSubTypes: true,
dedupeFragments: true,
preResolveTypes: true,
withHooks: true,
fetcher: {
endpoint: 'fetchConfig.endpoint',
fetchParams: 'fetchConfig.params',
},
},
},
},
};
export default config;