Skip to content

feat: enable to ignore cost weights on implementing types - #2976

Merged
ysmolski merged 8 commits into
mainfrom
yury/eng-9569-interface-field-cost-uses-max-across-implementations-instead
Jun 18, 2026
Merged

feat: enable to ignore cost weights on implementing types#2976
ysmolski merged 8 commits into
mainfrom
yury/eng-9569-interface-field-cost-uses-max-across-implementations-instead

Conversation

@ysmolski

@ysmolski ysmolski commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

This PR adds a feature flag that allows to emulate behavior
of Apollo that ignored weights on implementing types when
the fields on interface does not have cost weight assigned.

It includes the following fixes:

  • cost: determine correctly the type of list-wrapped scalars and enums (#1546) (2575480)
  • remove connections from transport connection pool (#1541) (ca47200)
  • resolve: fix GC-liveness bug in the loadBatchEntityFetch (#1536) (2ad6fc4)

Fixes ENG-9717
Fixes ENG-9779

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added security.cost_control.ignore_implementing_type_weights (default: false) to ignore @cost weights from implementing types on interface/union fields when the abstract type has no defined weight.
  • Tests
    • Added a cost-control test covering the new option, and adjusted related cost-estimation expectations.
  • Documentation
    • Updated the configuration schema and full config test data to include the new option.
  • Chores
    • Updated the underlying GraphQL tools dependency version.

This PR adds a feature flag that allows to emulate behavior
of Apollo which ignores weights on implementing types when
the field on interface does not have cost weight assigned.
@ysmolski
ysmolski requested a review from a team as a code owner June 17, 2026 10:17
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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

Adds a new IgnoreImplementingTypeWeights boolean flag to the CostControl configuration struct. The flag is wired through the planner builder, JSON schema and test fixtures are updated, graphql-go-tools/v2 is bumped to v2.5.0 in both modules, and integration tests verify the cost header behavior when the flag is enabled.

Changes

IgnoreImplementingTypeWeights Cost Control Feature

Layer / File(s) Summary
Config field, JSON schema, and test fixture
router/pkg/config/config.go, router/pkg/config/config.schema.json, router/pkg/config/testdata/config_full.json
CostControl struct gets IgnoreImplementingTypeWeights bool with YAML/env tags; the JSON schema adds the corresponding ignore_implementing_type_weights boolean under security.cost_control; the full-config fixture includes the new field set to false.
Planner wiring and dependency bump
router/core/executor.go, router/go.mod, router-tests/go.mod
buildPlannerConfiguration maps CostControl.IgnoreImplementingTypeWeights to planConfig.IgnoreImplementingTypeWeights; both go.mod files are bumped to graphql-go-tools/v2 v2.5.0.
Integration tests
router-tests/security/costs_test.go
New ignore_implementing_type_weights subtest enables the flag in measure mode, runs an interface-implementation query, and asserts that estimated and actual cost headers are lower than without the flag. Existing "nested list with inner object fields" test expectations are updated to reflect new cost calculations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • wundergraph/cosmo#2913: Touches the same graphql-go-tools/v2 dependency upgrade in both go.mod files.
  • wundergraph/cosmo#2925: Also modifies router cost calculation for abstract/interface fields, overlapping in cost-control and header computation areas.
🚥 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
Title check ✅ Passed The title accurately summarizes the main feature: enabling the ability to ignore cost weights on implementing types, which is the primary objective of this pull request.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

Router image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-7479af4db2ffa588841d70c7cf03213e508e32c2

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.45%. Comparing base (6e4ed19) to head (27769d1).

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2976       +/-   ##
===========================================
+ Coverage   41.75%   66.45%   +24.70%     
===========================================
  Files         142      258      +116     
  Lines       13755    27558    +13803     
  Branches      711        0      -711     
===========================================
+ Hits         5743    18314    +12571     
+ Misses       8010     7788      -222     
- Partials        2     1456     +1454     
Files with missing lines Coverage Δ
router/core/executor.go 89.06% <100.00%> (ø)
router/pkg/config/config.go 82.29% <ø> (ø)

... and 398 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.

@ysmolski
ysmolski merged commit 91039af into main Jun 18, 2026
37 checks passed
@ysmolski
ysmolski deleted the yury/eng-9569-interface-field-cost-uses-max-across-implementations-instead branch June 18, 2026 15:41
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.

2 participants