-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.ts
More file actions
48 lines (42 loc) · 1.84 KB
/
Copy pathcodegen.ts
File metadata and controls
48 lines (42 loc) · 1.84 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
40
41
42
43
44
45
46
47
48
/**
* GraphQL Code Generator configuration
*
* Purpose: Turn the Hasura GraphQL schema into typed TypeScript operations for
* every app surface. Uses client-preset for typed documents + typed helpers.
*
* Schema source: @nself/graphql-client/src/codegen/schema.graphql (committed snapshot).
* No live endpoint required — codegen works offline and in CI.
* To refresh the snapshot from the live endpoint, run:
* HASURA_GRAPHQL_ADMIN_SECRET=<secret> pnpm codegen:live
*
* Output: @nself/graphql-client/src/codegen/generated/
*
* Run: pnpm codegen
* CI: pnpm codegen:check
*
* Constraints:
* - Schema is a committed SDL file — no network dependency during codegen.
* - documents glob is scoped to packages only — never node_modules.
* - ignoreNoDocuments: true — pipeline is green before any .graphql op files exist.
* - Fragment masking uses getFragmentData unmask helper.
*/
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
// Use committed schema snapshot — works offline and in CI without admin-secret.
schema: './@nself/graphql-client/src/codegen/schema.graphql',
// Scoped glob — never use **/*.graphql (would pull node_modules / sub-repo output)
documents: ['@nself/**/*.graphql', '!@nself/graphql-client/src/codegen/schema.graphql'],
// Prevent codegen from erroring when no .graphql operation files exist yet.
ignoreNoDocuments: true,
generates: {
'./@nself/graphql-client/src/codegen/generated/': {
preset: 'client',
presetConfig: {
// Require getFragmentData() helper for masked fragments — prevents accidental
// direct access to masked fragment data in consuming apps.
fragmentMasking: { unmaskFunctionName: 'getFragmentData' },
},
},
},
};
export default config;