# graphql-codegen configuration # # Schema source: combined-schema.graphql (generated by scripts/normalize-schema.ts # from services subgraph SDL files, with federation `extend type Query` normalized). # # Subgraph list (7 with GraphQL): iam / config-service / core-edu / content / # msg / data-ana / ai (classes has no GraphQL subgraph yet). # # Outputs: # - __generated__/types.ts: all GraphQL schema types (always generated) # - __generated__/operations.ts: DocumentNode constants emitted from # operations/*.graphql.ts via typescript-document-nodes plugin. # - __generated__/dashboard-types.ts: per-operation types for data-ana domain # (skipDocumentsValidation: false). Other domains still reference forward-looking # spec fields not yet in services subgraph SDL; they remain on the global # skipDocumentsValidation: true. As services catch up, additional per-domain # outputs can be added (config → core-edu → content → msg → iam order). # # Related: spec section 2.4 / 5.3, ARCHITECTURE.md §10 P1-7 schema: - src/lib/api/__generated__/combined-schema.graphql # Schema validation is skipped because services/ai subgraph has invalid input # types (ChatRequestInput.messages references output type ChatMessage; same # for ChatResponseInput.usage → Usage). normalize-schema.ts rewrites those # field types to String as a codegen-only sanitize. skipSchemaValidation: true generates: src/lib/api/__generated__/types.ts: plugins: - typescript src/lib/api/__generated__/operations.ts: # typescript-document-nodes only: emits typed DocumentNode constants # from the gql templates in operations/*.graphql.ts. We deliberately # omit typescript-operations here because portal-shell widgets use # forward-looking spec fields (grades, myClasses, lessonPlans, etc.) # that are not yet present in services subgraph SDL; once services # catch up we can re-add typescript-operations for full query typing. # Per-domain typed outputs (e.g. dashboard-types.ts) cover the # operations whose fields DO match the schema today (P1-7). documents: src/lib/api/operations/**/*.graphql.ts plugins: - typescript-document-nodes # P1-7: data-ana domain (dashboard.graphql.ts) — skipDocumentsValidation # closed because all 6 operations strictly match the schema. Generates # per-operation types so lib/api/dashboard.ts can drop its hand-written # interfaces. Config domain closure deferred until LayoutTemplateGql # schema adds `availableSlots` (admin.graphql.ts GET_LAYOUT_TEMPLATES_DOC # queries that field but it is not yet in the subgraph SDL). src/lib/api/__generated__/dashboard-types.ts: documents: src/lib/api/operations/dashboard.graphql.ts plugins: - typescript - typescript-operations config: skipDocumentsValidation: false config: preResolveTypes: true skipTypename: true exportTypeKeyOnly: true useTypeImports: true # Generated operations.ts should import `gql` from @apollo/client (the # package portal-shell actually uses) instead of the default graphql-tag. gqlImport: "@apollo/client#gql" # Skip document validation against schema. portal-shell widgets use spec # forward-looking fields (grades, myClasses, lessonPlans, etc.) not yet # implemented in services subgraph SDL. Without this flag, codegen would # emit 44 "Cannot query Field X on type Query" errors and refuse to write # operations.ts. The runtime apollo-router validates documents at request # time, so skipping here only affects codegen-time type generation. # Per-output overrides (see dashboard-types.ts above) close this flag for # specific domains whose operations DO match the schema (P1-7). skipDocumentsValidation: true