-
-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathcodegen.ts
More file actions
36 lines (34 loc) · 1.71 KB
/
Copy pathcodegen.ts
File metadata and controls
36 lines (34 loc) · 1.71 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
import type { CodegenConfig } from "@graphql-codegen/cli";
// GraphQL codegen (types-epic D, #7862): schema points at src/graphql-sdl.ts
// (the SDL string extracted from src/graphql.ts specifically so codegen's
// module-import schema loader doesn't drag in that file's full resolver map
// as a side effect of every codegen run — see graphql-sdl.ts's own header).
// `generated/graphql/types.ts` is the ONLY output; nothing else is written.
const config: CodegenConfig = {
schema: "src/graphql-sdl.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;