-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.ts
39 lines (37 loc) · 1.06 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
// codegen.ts
import { type CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
schema: "https://swapi-graphql.netlify.app/.netlify/functions/index",
documents: "graphql/**/*.graphql",
generates: {
// generate types.ts
"graphql/types.ts": { plugins: ["typescript"] },
// generate operations.ts
"graphql/operations.ts": {
preset: "import-types",
plugins: ["typescript-operations", "typescript-urql"],
presetConfig: {
typesPath: "./types",
},
config: {
withHooks: false,
},
},
// generate hooks in separate files - optional
hooks: {
preset: "near-operation-file",
presetConfig: {
extension: ".hooks.tsx",
baseTypesPath: "../types.ts",
},
plugins: ["typescript-urql"],
config: {
withHooks: true,
importOperationTypesFrom: "Operations",
documentMode: "external",
importDocumentNodeExternallyFrom: "./operations.tsx",
},
},
},
};
export default config;