Skip to content

feat: v2 — config redesign, schema checks, and tooling modernization#39

Open
mwisner wants to merge 11 commits intowundergraph:mainfrom
mwisner:v2
Open

feat: v2 — config redesign, schema checks, and tooling modernization#39
mwisner wants to merge 11 commits intowundergraph:mainfrom
mwisner:v2

Conversation

@mwisner
Copy link
Copy Markdown

@mwisner mwisner commented Mar 17, 2026

Summary

This is a major rework of the Cosmo Previews action, focused on three areas:

1. Config schema redesign

The cosmo.yaml format has been restructured for clarity and flexibility:

  • Top-level subgraphs with typed support (standard, edfs, grpc) — only standard subgraphs can be previewed, but all types can be checked
  • previews section replaces the flat feature_flags / subgraphs pairing — each preview has its own name, namespace, labels, and subgraph references with routing_url templates
  • check section for multi-namespace schema checks
  • Cross-validation via Zod .refine() ensures preview subgraph references point to existing standard subgraphs

Before (v1):

namespace: 'dev1'
feature_flags:
  - name: 'my-flag'
    labels:
      - 'graph=private'
subgraphs:
  - name: 'my-subgraph'
    schema_path: 'schema.graphqls'
    routing_url: 'http://my-svc-pr-${PR_NUMBER}.example.com/graphql'

After (v2):

version: '1'
subgraphs:
  - name: 'my-subgraph'
    schema_path: 'schema.graphqls'
  - name: 'events'
    type: edfs
    schema_path: 'events.graphqls'

previews:
  - name: 'my-preview'
    namespace: 'dev1'
    labels:
      - 'graph=private'
    subgraphs:
      - name: 'my-subgraph'
        routing_url: 'http://my-svc-pr-${PR_NUMBER}.example.com/graphql'

check:
  namespaces:
    - dev1
    - staging

2. Schema check support

New action: schema / stage: check mode that:

  • Runs wgc subgraph check against all configured subgraphs across all namespaces in the check section
  • Posts/updates a PR comment with a summary table (status, aggregated error/warning counts, Studio link)
  • When issues exist, adds a collapsible <details> section per namespace/subgraph with full tables for:
    • Breaking changes
    • Composition errors/warnings
    • Lint errors/warnings
    • Graph pruning errors/warnings
  • Uses --out flag for reliable JSON parsing (stdout from wgc -j outputs JS object notation, not valid JSON)

3. Tooling modernization

  • pnpm replaces npm
  • tsdown (rolldown-based) replaces ncc for bundling — single ESM output
  • oxlint + oxfmt replace ESLint + Prettier
  • vitest replaces jest
  • lefthook for pre-commit hooks (format + lint)
  • Node 24 runtime (using: node24 in action.yml)
  • Zod v4 for all input/config validation with discriminated unions

4. Action input changes

The boolean create/update/destroy inputs are replaced with explicit action + stage:

action stage description
preview create Create feature flag + subgraphs
preview update Update feature subgraphs
preview delete Destroy feature flag + subgraphs
schema check Run schema checks and post PR comment

Breaking Changes

  • Config format (cosmo.yaml) is completely different — see migration example above
  • Action inputs changed from create/update/destroy booleans to action/stage strings
  • cosmo_api_key and github_token are now required inputs
  • Runtime changed from Node 20 to Node 24
  • Bundle format changed from CJS (dist/index.js) to ESM (dist/index.mjs)
  • wgc CLI is no longer bundled — must be installed in the workflow (npm i -g wgc@latest)

Test Plan

  • Unit tests for config schema validation (12 tests)
  • Unit tests for schema check output formatting (14 tests)
  • Tested preview create/update/delete lifecycle on live repo
  • Tested schema check with clean schema (all green, no details section)
  • Tested schema check with breaking changes (error status, collapsible details with breaking change table)
  • Tested schema check with lint warnings (warning counts in summary, lint table in details)

AI Disclosure

This pull request was developed with assistance from Claude Code (Claude Opus 4.6, Anthropic's AI coding assistant). Claude helped with:

  • Code generation for the schema check implementation, config schema redesign, and test files
  • Tooling migration (pnpm, tsdown, oxlint, vitest configuration)
  • PR comment markdown formatting logic
  • Writing this pull request description

All code was reviewed, tested, and validated by a human contributor. The architectural decisions (config schema design, preview abstraction, schema check behavior) were directed by the human author through iterative feedback.


🤖 Generated with Claude Code

mwisner and others added 11 commits March 17, 2026 13:45
- Switch from npm to pnpm 10.32
- Replace ncc with tsdown (ESM bundle-all)
- Replace eslint/prettier with oxlint + oxfmt + lefthook
- Replace jest with vitest
- Upgrade to Node 24, ES2024, bundler module resolution
- Add GHA quality workflow (build, types, lint, test, format)
- Bump all deps: @actions/core v3, @actions/github v9, @actions/exec v3,
  @octokit/rest v22, wgc v0.112, pathe v2, @types/node v25
- Fix DeploymentError.featureFlag removal in wgc v0.112
- Fix Context import for @actions/github v9

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Zod v4 schema validation replacing unsafe `as Config` casts
- Restructure cosmo.yaml: top-level `subgraphs` (with type: standard|edfs|grpc),
  `previews` (namespace, labels, subgraph routing URLs), and `check` (namespaces)
- Refactor action inputs from boolean flags to action/stage string system
- Reorganize code into src/actions/preview.ts and src/actions/schema.ts
- Preview subgraphs reference top-level subgraphs by name with routing URL templates
- Cross-validate preview references against existing standard subgraphs
- Feature flags are now an implementation detail abstracted behind previews

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Run `wgc subgraph check` with JSON output for each changed subgraph
  against all namespaces defined in check.namespaces
- Post upsertable PR comment with summary table (namespace, subgraph,
  status, lint error/warning counts, Studio link)
- Fail the action if any check has non-success status
- Add schema_check_results output for downstream workflow steps

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Basic tests for configSchema and actionInputSchema covering:
- Minimal valid config, subgraph type defaults, edfs/grpc types
- Full config with previews and check sections
- Cross-validation: reject preview referencing non-existent or non-standard subgraphs
- Action/stage discriminated union validation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The action shells out to `wgc` via exec but the bundled code doesn't
put it in PATH. Install it globally at the start of each run so
consumers don't need to handle it in their workflows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Schema checks should always report on all subgraphs, not just
ones with changed files in the PR.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove runtime wgc install (consumers provide it in their workflow)
- Use `--out` flag to write check results to a temp file instead of
  parsing stdout, which outputs JS object notation rather than JSON

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When lint warnings/errors, breaking changes, composition issues, or
graph pruning issues are found, a collapsible details section is added
below the summary table for each affected namespace/subgraph combo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests for hasIssues and buildDetailsSection covering lint warnings,
breaking changes, composition errors, graph pruning, multi-result
rendering, and edge cases like missing line numbers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The summary table now shows total errors (breaking changes, composition
errors, lint errors, graph prune errors) and total warnings across all
issue types, so the counts align with the status column.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant