-
-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathcodegen.ts
More file actions
37 lines (35 loc) · 1.79 KB
/
Copy pathcodegen.ts
File metadata and controls
37 lines (35 loc) · 1.79 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
import type { CodegenConfig } from "@graphql-codegen/cli";
// GraphQL codegen (types-epic D, #7862): schema points at the generated SDL
// module (#10214) — a dependency-free file, so codegen's module-import schema
// loader doesn't drag in src/graphql.ts's full resolver map as a side effect
// of every codegen run. scripts/generate-graphql-types.ts emits that module
// from the Zod-built schema BEFORE running this config against it.
// `generated/graphql/types.ts` is the ONLY output; nothing else is written.
const config: CodegenConfig = {
schema: "generated/graphql/schema.ts",
generates: {
"generated/graphql/types.ts": {
plugins: ["typescript", "typescript-resolvers"],
config: {
// JSON is the SDL's opaque-value scalar (incident by_kind maps,
// Adapter's snapshot/extensions, etc.) — matches how the MCP mirror
// and workers/data-api.ts treat the same shapes: unknown, not any.
scalars: { JSON: "unknown" },
// src/graphql.ts's `GqlContext` (exported for exactly this) — every
// resolver's contextValue in the real rootValue object. Path is
// relative to the OUTPUT file (generated/graphql/types.ts), so two
// levels up to the repo root, then into src/.
contextType: "../../src/graphql.ts#GqlContext",
// We want exact generated types, not every field auto-wrapped in
// Partial<T> (typescript-resolvers' default "loose" mapper).
defaultMapper: "{T}",
// rootValue is a plain object of resolver methods (graphql-js
// default-field-resolver style), not an Apollo-style per-type
// resolver map — makeResolverTypeUnion off keeps the generated
// Resolvers shape matching that.
useIndexSignature: true,
},
},
},
};
export default config;