Skip to content

Considered @oneOf in CostAnalysis#9549

Open
N-Olbert wants to merge 10 commits intoChilliCream:mainfrom
N-Olbert:OneOf-Cost
Open

Considered @oneOf in CostAnalysis#9549
N-Olbert wants to merge 10 commits intoChilliCream:mainfrom
N-Olbert:OneOf-Cost

Conversation

@N-Olbert
Copy link
Copy Markdown
Contributor

Summary of the changes (Less than 80 chars)

  • Considered @OneOf in CostAnalysis
  • Assume only one level of recursion for circular fields.
  • If required, this could be made configurable within the ModifyCostOptions/ costOptions (bool ConsiderOneOf and int AssumedRecursionDepthor so)

Closes #9547 (in this specific format)
Closes #9548

Assume only one level of recursion for circular fields.
Copilot AI review requested due to automatic review settings April 14, 2026 21:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates HotChocolate CostAnalysis input-cost computation to better match GraphQL @oneOf semantics and to avoid over-counting for circular input object references.

Changes:

  • Update variable-based input object cost calculation to treat @oneOf input objects as max(fieldCost) instead of sum(fieldCost).
  • Adjust circular input object traversal to stop on re-entry (assume a single recursion level).
  • Add new OneOfCostTests and update an existing paging/filtering snapshot to reflect the new cost results.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/HotChocolate/CostAnalysis/src/CostAnalysis/Utilities/InputCostVisitor.cs Reworks variable input-object cost computation (adds @oneOf max-cost and loop short-circuit).
src/HotChocolate/CostAnalysis/src/CostAnalysis/Utilities/InputCostVisitorContext.cs Replaces backlog-based traversal state with processed-set + per-type cost cache.
src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/OneOfCostTests.cs Adds test coverage for @oneOf cost behavior (variables, nesting, lists).
src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/snapshots/PagingTests.Filtering_Variable.md Updates expected snapshot output due to changed variable input-cost computation.

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

Comment thread src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/OneOfCostTests.cs Outdated
Comment thread src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/OneOfCostTests.cs Outdated
Comment thread src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/OneOfCostTests.cs Outdated
Comment thread src/HotChocolate/CostAnalysis/src/CostAnalysis/Utilities/InputCostVisitor.cs Outdated
Comment thread src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/OneOfCostTests.cs Outdated
@glen-84 glen-84 changed the title Considered @OneOf in CostAnalysis Considered @oneOf in CostAnalysis Apr 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


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

Comment thread src/HotChocolate/CostAnalysis/src/CostAnalysis/Utilities/InputCostVisitor.cs Outdated
Comment thread src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/OneOfCostTests.cs Outdated
N-Olbert and others added 3 commits April 16, 2026 23:22
…CostVisitor.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


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

Comment thread src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/CostAnalysisTestHelper.cs Outdated
Comment thread src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/CostAnalysisTestHelper.cs Outdated
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.

Cost assuming two levels of recursion for circular references Too high cost emitted for @OneOf-InputTypes

2 participants