Skip to content

fix(router): incorrect alias behavior for required fields#3101

Draft
Noroth wants to merge 2 commits into
mainfrom
ludwig/router-581-engine-alias-on-required-fields-is-misbehaving
Draft

fix(router): incorrect alias behavior for required fields#3101
Noroth wants to merge 2 commits into
mainfrom
ludwig/router-581-engine-alias-on-required-fields-is-misbehaving

Conversation

@Noroth

@Noroth Noroth commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved GraphQL field resolution for aliased fields using @requires.
    • Corrected handling of aliases for nested abstract values and composite @requires fields.
    • Ensured missing employees correctly return null responses in aliased queries.
  • Tests
    • Added coverage for aliased field resolution and related null-response scenarios.

Checklist

Open Source AI Manifesto

This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

❌ Internal Query Planner CI checks failed

The Internal Query Planner CI checks failed in the celestial repository, and this is going to stop the merge of this PR.
If you are part of the WunderGraph organization, you can see the PR with more details.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The router and router-tests modules update graphql-go-tools/v2. gRPC subgraph tests add alias coverage for tagged, nested abstract, and composite @requires field resolution.

Changes

@requires alias coverage

Layer / File(s) Summary
Dependency update and alias regression coverage
router/go.mod, router-tests/go.mod, router-tests/protocol/grpc_subgraph_test.go
Updates graphql-go-tools/v2 to the newer pseudo-version and adds tests for aliased @requires fields, nested abstract values, and null composite results.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing router alias behavior for required fields.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.02%. Comparing base (85f3294) to head (9d3f481).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3101      +/-   ##
==========================================
+ Coverage   61.83%   62.02%   +0.19%     
==========================================
  Files         262      262              
  Lines       30810    30810              
==========================================
+ Hits        19050    19111      +61     
+ Misses      10232    10187      -45     
+ Partials     1528     1512      -16     

see 12 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@router-tests/protocol/grpc_subgraph_test.go`:
- Around line 415-419: Add a test case in the existing employee query coverage
using the aliased field `aliasedReviewReport: reviewReport`, and assert its
expected non-null value to exercise alias resolution. Retain the current
non-existent employee null-propagation case only if it is still required by the
test contract.
🪄 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: f34580ef-0c6b-4740-b80c-93dfc71feace

📥 Commits

Reviewing files that changed from the base of the PR and between 991a647 and 9d3f481.

⛔ Files ignored due to path filters (2)
  • router-tests/go.sum is excluded by !**/*.sum
  • router/go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • router-tests/go.mod
  • router-tests/protocol/grpc_subgraph_test.go
  • router/go.mod

Comment on lines +415 to +419
{
name: "query non-existent employee with @requires and aliased fields returns null",
query: `{ employee(id: 999) { id workItemInfo reviewReport aliasedReviewReport: reviewReport } }`,
expected: `{"data":{"employee":null}}`,
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the file structure first, then inspect the relevant slice.
git ls-files 'router-tests/protocol/*' | sed -n '1,120p'
echo '--- outline ---'
ast-grep outline router-tests/protocol/grpc_subgraph_test.go --view expanded || true
echo '--- lines 360-470 ---'
sed -n '360,470p' router-tests/protocol/grpc_subgraph_test.go
echo '--- search for employee/reviewReport/aliasedReviewReport ---'
rg -n "reviewReport|aliasedReviewReport|`@requires`|employee\\(" router-tests/protocol/grpc_subgraph_test.go

Repository: wundergraph/cosmo

Length of output: 18542


Add an aliased reviewReport case on an existing employee.
This null-only query doesn’t exercise alias resolution, so it can still pass if aliasedReviewReport is broken. Add a case with an existing employee and assert the aliased field value; keep the null-propagation case only if that behavior is required.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@router-tests/protocol/grpc_subgraph_test.go` around lines 415 - 419, Add a
test case in the existing employee query coverage using the aliased field
`aliasedReviewReport: reviewReport`, and assert its expected non-null value to
exercise alias resolution. Retain the current non-existent employee
null-propagation case only if it is still required by the test contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant