Skip to content

chore(demo): fix code generation for cost directives#2667

Merged
ysmolski merged 8 commits intomainfrom
yury/fix_demo_generate
Mar 19, 2026
Merged

chore(demo): fix code generation for cost directives#2667
ysmolski merged 8 commits intomainfrom
yury/fix_demo_generate

Conversation

@ysmolski
Copy link
Copy Markdown
Contributor

@ysmolski ysmolski commented Mar 19, 2026

Include new directives into the schemas to make gqlgen happy.

Fixes ENG-9243

Summary by CodeRabbit

  • Chores

    • Bumped Go module and developer-tooling dependencies to newer versions.
  • New Features

    • Introduced @cost and @listsize GraphQL directives to annotate cost and list-sizing metadata.
  • Configuration

    • GraphQL codegen configured to skip runtime handling for the new directives.
  • CI

    • Added a Demo CI workflow to run generation and checks for demo changes.
  • Tests

    • Updated test/demo GraphQL schemas and test configs, including several field nullability and list-element signature adjustments.

Include new directives into the schemas to make gqlgen happy.
@ysmolski ysmolski requested review from a team as code owners March 19, 2026 12:13
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 19, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Updated demo and router-tests Go module pins and indirect deps; added explicit GraphQL directive definitions (@cost, @listSize) to subgraph SDLs and JSON-embedded SDLs used in tests; configured gqlgen to skip runtime for those directives; added a Demo CI workflow; adjusted small schema nullability/return-type signatures in test SDLs.

Changes

Cohort / File(s) Summary
Go module files
demo/go.mod, router-tests/go.mod
Bumped github.com/wundergraph/cosmo/router/router-tests pins and updated indirect deps (connectrpc.com/connect → v1.19.1; added connectrpc.com/vanguard v0.3.0; bumped github.com/wundergraph/astjson and github.com/wundergraph/graphql-go-tools/v2).
Subgraph schemas
demo/pkg/subgraphs/employees/subgraph/schema.graphqls, demo/pkg/subgraphs/products/subgraph/schema.graphqls
Added directive definitions: directive @cost(weight: Int!) (ARGUMENT_DEFINITION
gqlgen configs
demo/pkg/subgraphs/employees/gqlgen.yml, demo/pkg/subgraphs/products/gqlgen.yml
Added directives entries for cost and listSize with skip_runtime: true (employees updated; products received a new block).
Router-tests embedded SDLs
router-tests/testenv/testdata/config.json, router-tests/testenv/testdata/configWithEdfs.json
Updated JSON-embedded customGraphql.federation.serviceSdl strings to include the new directive definitions and adjusted several field return/nullability signatures and minor schema variants used by tests (e.g., [Employee][Employee!]!, some IntInt!, input field nullability changes).
CI workflows
.github/workflows/demo-ci.yaml, .github/workflows/router-ci.yaml
Added new "Demo CI" workflow (runs demo generate/test and git-dirty check for demo/* PRs); renamed a workflow step and added demo-driven test config generation plus replaced inline git-dirty check with reusable action in router CI.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding cost and listSize directive definitions to GraphQL schemas and their gqlgen configurations to fix code generation issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 19, 2026

Router-nonroot image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-4734a193ac0ac5717da37d0dcb4454ff37fc4ec6-nonroot

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@demo/go.mod`:
- Line 152: The dependency entry for github.com/wundergraph/graphql-go-tools/v2
is updated to a release-candidate v2.0.0-rc.265; decide whether to pin this
exact RC or revert to a stable release: update the go.mod entry to either keep
the exact version v2.0.0-rc.265 (to lock behavior and plan a future migration
when v2.0.0 GA is released) or change it to the latest stable GA when
API-stability is required, and document the chosen strategy in the repo’s
dependency policy so maintainers know to revisit the RC once v2.0.0 final is
published.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7d184b58-d803-4a07-bb7a-a4ef59500947

📥 Commits

Reviewing files that changed from the base of the PR and between 0e5fa81 and e5b43f8.

⛔ Files ignored due to path filters (3)
  • demo/go.sum is excluded by !**/*.sum
  • demo/pkg/subgraphs/employees/subgraph/generated/generated.go is excluded by !**/generated/**
  • demo/pkg/subgraphs/products/subgraph/generated/generated.go is excluded by !**/generated/**
📒 Files selected for processing (3)
  • demo/go.mod
  • demo/pkg/subgraphs/employees/subgraph/schema.graphqls
  • demo/pkg/subgraphs/products/subgraph/schema.graphqls

Comment thread demo/go.mod
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.01%. Comparing base (9a96032) to head (21b3192).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2667      +/-   ##
==========================================
+ Coverage   62.81%   63.01%   +0.20%     
==========================================
  Files         245      245              
  Lines       26260    26260              
==========================================
+ Hits        16496    16549      +53     
+ Misses       8407     8366      -41     
+ Partials     1357     1345      -12     

see 17 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread demo/pkg/subgraphs/employees/subgraph/schema.graphqls
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
router-tests/testenv/testdata/configWithEdfs.json (1)

3248-3248: Consider sourcing the duplicated employees SDL from one place.

This is effectively a second full copy of the Line 203 SDL. If this fixture stays hand-maintained, generating both values from the same source would reduce drift the next time the demo schema changes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@router-tests/testenv/testdata/configWithEdfs.json` at line 3248, The file
contains a duplicated GraphQL SDL string assigned to the serviceSdl field (a
second full copy of the employees SDL); extract the common SDL into a single
shared source (e.g., a constant or fixture used by both places) and replace this
literal in serviceSdl with a reference to that shared symbol (ensure the shared
symbol name is descriptive like EMPLOYEES_SDL or sharedServiceSdl and update any
tests/fixtures that currently embed the duplicate so both use the same value).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/demo-ci.yaml:
- Around line 8-10: The concurrency group currently uses github.head_ref which
groups runs by branch name and can cancel unrelated PRs; update the concurrency
group expression to include the PR number (e.g. use
github.event.pull_request.number) so runs are isolated per PR. Locate the
concurrency block (symbol: concurrency, keys: group and cancel-in-progress) and
replace or augment github.head_ref in the group expression with
github.event.pull_request.number (or fallback to github.run_id for non-PR
events) to ensure only the same PR run cancels in-progress jobs.

---

Nitpick comments:
In `@router-tests/testenv/testdata/configWithEdfs.json`:
- Line 3248: The file contains a duplicated GraphQL SDL string assigned to the
serviceSdl field (a second full copy of the employees SDL); extract the common
SDL into a single shared source (e.g., a constant or fixture used by both
places) and replace this literal in serviceSdl with a reference to that shared
symbol (ensure the shared symbol name is descriptive like EMPLOYEES_SDL or
sharedServiceSdl and update any tests/fixtures that currently embed the
duplicate so both use the same value).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f22b7f4a-28b2-4396-bc81-d50c0cd61bd1

📥 Commits

Reviewing files that changed from the base of the PR and between 18d9e49 and a5f3b70.

📒 Files selected for processing (3)
  • .github/workflows/demo-ci.yaml
  • router-tests/testenv/testdata/config.json
  • router-tests/testenv/testdata/configWithEdfs.json

Comment thread .github/workflows/demo-ci.yaml
@ysmolski ysmolski requested a review from Noroth March 19, 2026 14:36
@ysmolski ysmolski requested a review from comatory March 19, 2026 14:48
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/router-ci.yaml:
- Around line 165-167: The "Generate test configs from demo" workflow step uses
"run: update-config-no-edg.sh" which fails without an explicit path; update the
step so the run command invokes the script with a relative path (e.g., change to
"./update-config-no-edg.sh") while keeping the existing working-directory
(router-tests) so the script is executed from the correct folder.
- Around line 69-71: The workflow invokes the script by bare name
"update-config-no-edg.sh", which fails because the shell won't search the
current directory; update both occurrences of the invocation (the steps that run
update-config-no-edg.sh, e.g., the step titled "Generate test configs from demo"
and the other symmetric invocation later) to call it with a ./ prefix
("./update-config-no-edg.sh") so the script is executed from the working
directory.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 22717464-f9ce-4983-b4d6-e7890dad8be7

📥 Commits

Reviewing files that changed from the base of the PR and between a5f3b70 and d9b7958.

📒 Files selected for processing (1)
  • .github/workflows/router-ci.yaml

Comment thread .github/workflows/router-ci.yaml Outdated
Comment thread .github/workflows/router-ci.yaml Outdated
@ysmolski ysmolski merged commit 6936d4d into main Mar 19, 2026
37 checks passed
@ysmolski ysmolski deleted the yury/fix_demo_generate branch March 19, 2026 17:01
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.

2 participants