Skip to content

Fix issue in the cost analyzer that deduplicated too aggressively - #9916

Merged
michaelstaib merged 5 commits into
mainfrom
mst/cost-issue
Jun 16, 2026
Merged

michaelstaib merged 5 commits into
mainfrom
mst/cost-issue

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 15, 2026 09:06

Copilot AI 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.

Pull request overview

This PR adjusts the cost analysis “response name deduplication” behavior so that repeated response names (e.g., nodes, edges, pageInfo) are only deduplicated within a single selection set, ensuring nested connections and sibling selections are fully costed.

Changes:

  • Reset per-selection-set response-name tracking in CostAnalyzer.CalculateSelectionSetCost so nested selection sets can reuse response names without being skipped.
  • Add targeted tests covering flat connections, nested fan-out, limit enforcement, and sibling aliased connections.
  • Update the existing static query analysis snapshot to reflect the corrected cost calculation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/HotChocolate/CostAnalysis/src/CostAnalysis/CostAnalyzer.cs Clears the shared Processed set per selection set and reorders the conditional so deduplication happens only after type/field applicability is confirmed.
src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/NestedConnectionCostTests.cs Adds regression tests verifying nested and sibling connection costing and cost-limit rejection behavior.
src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/__snapshots__/StaticQueryAnalysisTests.Execute_ConnectionQuery_ReturnsExpectedResult_0.md Updates expected operationCost values to match the corrected costing logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@michaelstaib michaelstaib changed the title Fixed issue in the cost analyzer that deduplicated to aggressively Fix issue in the cost analyzer that deduplicated too aggressively Jun 15, 2026
@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall coverage in the mst/cost-issue branch is 49%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main mst/cost-issue 413cb38 +/-
/home/runner/wo.../FieldResult.cs — 100% —
/home/runner/wo...SchemaMerger.cs — 98% —
/home/runner/wo...xecutionTree.cs — 92% —
/home/runner/wo...ationPlanner.cs — 88% —
/home/runner/wo...mentRewriter.cs — 87% —
/home/runner/wo...eBuilderBase.cs — 85% —
/home/runner/wo...xGenerator.g.cs — 80% —
/home/runner/wo...hResultStore.cs — 80% —
/home/runner/wo...xGenerator.g.cs — 71% —
/home/runner/wo...lient.Client.cs — 1% —

Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@michaelstaib
michaelstaib merged commit a48b600 into main Jun 16, 2026
145 checks passed
@michaelstaib
michaelstaib deleted the mst/cost-issue branch June 16, 2026 06:30
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