Repository navigation
Expand file tree
/
Copy pathcodegen.ts
More file actions
39 lines (37 loc) · 1.44 KB
/
Copy pathcodegen.ts
File metadata and controls
39 lines (37 loc) · 1.44 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
import type { CodegenConfig } from "@graphql-codegen/cli";
/**
* Schema-first contract codegen (spec 007).
*
* `schema.graphql` is the single source of truth. Each consumer wires its own
* output here from its spec — generated code lives WITH its consumer, not in a
* shared package:
* - services/api -> typescript + typescript-resolvers (spec 008)
* - apps/web -> client preset / typed documents (wizard spec)
*
* Until a consumer adds an entry, `generates` is empty and the contract is
* guarded by `yarn codegen:check` (see scripts/codegen-check.mjs), which fails
* the build on an invalid schema.
*/
const config: CodegenConfig = {
schema: "./schema.graphql",
generates: {
"services/api/src/__generated__/resolvers.ts": {
plugins: ["typescript", "typescript-resolvers"],
},
// apps/web — typed documents (client preset). Operations live in
// apps/web/lib/graphql/**; the wizard imports the generated TypedDocumentNodes
// and never hand-writes a network type. Enums emit as string unions so the
// wizard's stored values (e.g. "EVERY_2_WEEKS") pass straight into variables.
"apps/web/lib/gql/": {
preset: "client",
documents: ["apps/web/lib/graphql/**/*.ts"],
presetConfig: { fragmentMasking: false },
config: {
enumsAsTypes: true,
scalars: { Date: "string", DateTime: "string" },
useTypeImports: true,
},
},
},
};
export default config;