/** * Config shape for the shared MFE GraphQL schema-drift validator (BOFF-3922). * * One `schema-drift.config.json` lives at the root of a consuming MFE repo. * See README.md in this directory for the full guide and worked examples. */ /** * A named set of schema SDL file(s) that form one validation target. * * A document is considered clean if it validates against **at least one** * configured group (fallback semantics — this is how a repo whose components * legitimately call root fields owned by a different subgraph, e.g. a shared * TagPicker calling wspace-tags-svc fields, can validate against its own * subgraph first and the composed gateway snapshot second). * * Multiple `files` within the SAME group are concatenated into one schema * (this is how a subgraph's base types + a separately-published gateway-roots * extension file are validated as a single schema — see `mergeExtends`). */ export interface SchemaGroupConfig { /** Human-readable label used only in error output. */ name: string; /** SDL file paths, relative to the repo root (the config file's directory). */ files: string[]; /** * When true, `extend type X` / `extend interface X` in every file of this * group is rewritten to a plain `type X` / `interface X` before the files * are concatenated. Use this when one file declares `extend type Query` * against root fields that only exist in the composed supergraph (not in * the base SDL file itself) — without the rewrite, `buildSchema` would * reject the `extend` because it has nothing to extend. */ mergeExtends?: boolean; } /** A directory of `.ts`/`.tsx` source files to scan for inline GraphQL documents. */ export interface SourceRootConfig { /** Directory path, relative to the repo root. Scanned recursively. */ dir: string; /** File extensions to scan. Defaults to `['.ts', '.tsx']`. */ extensions?: string[]; } export interface SchemaDriftConfig { /** * Directories to scan for inline GraphQL operations — template literals * (optionally `gql`-tagged) whose content starts with `query`, `mutation`, * or `subscription`. This is the primary extraction mode: it is what * catches drift in hand-rolled documents that `graphql-codegen` never sees * because they aren't `.graphql` files on its `documents:` glob. */ sourceRoots: SourceRootConfig[]; /** * Extra directories of standalone `.graphql`/`.gql` fragment files to * resolve `...FragmentName` spreads against, in addition to any `fragment` * blocks found inline within `sourceRoots` (those are always collected * automatically). Optional — omit if the repo has no separate fragment * files. */ fragmentDirs?: string[]; /** One or more schema groups. A document must validate against at least one. */ schemaGroups: SchemaGroupConfig[]; /** * When an inline operation contains an unresolved `${...}` interpolation * (i.e. not a same-file top-level `const NAME = \`...\`` this tool can * expand), fail loudly instead of silently stripping it — a stripped * interpolation can hide the exact selection set that would actually * reveal drift. Defaults to `true`. Only set `false` if a repo has a * verified reason every such interpolation is validation-irrelevant. */ treatUnresolvedInterpolationAsError?: boolean; }