-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.ts
40 lines (38 loc) · 1.16 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
import { CodegenConfig } from '@graphql-codegen/cli';
const endpointOverride = process.env.CONTENTFUL_GRAPHQL_ENDPOINT;
const productionEndpoint = 'https://graphql.contentful.com/content/v1/spaces';
export const endpoint = `${endpointOverride || productionEndpoint}/${process.env.CONTENTFUL_SPACE_ID}`;
export const config: CodegenConfig = {
overwrite: true,
ignoreNoDocuments: true,
schema: [
{
[endpoint || '']: {
headers: {
Authorization: `Bearer ${process.env.CONTENTFUL_ACCESS_TOKEN}`,
},
},
},
],
generates: {
'src/lib/__generated/graphql.schema.json': {
plugins: ['introspection'],
},
'src/lib/__generated/graphql.schema.graphql': {
plugins: ['schema-ast'],
},
'src/lib/__generated/sdk.ts': {
documents: ['src/lib/graphql/**/*.graphql'],
plugins: ['typescript', 'typescript-operations', 'typescript-graphql-request'],
config: {
rawRequest: false,
inlineFragmentTypes: 'combine',
skipTypename: false,
exportFragmentSpreadSubTypes: true,
dedupeFragments: true,
preResolveTypes: true,
},
},
},
};
export default config;