-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.ts
46 lines (44 loc) · 1.23 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
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: {
"lib/contentful/__generated/graphql.schema.json": {
plugins: ["introspection"],
},
"lib/contentful/__generated/graphql.schema.graphql": {
plugins: ["schema-ast"],
},
"lib/contentful/__generated/sdk.ts": {
documents: ["lib/contentful/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;