Considered @oneOf in CostAnalysis#9549
Conversation
Assume only one level of recursion for circular fields.
There was a problem hiding this comment.
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
@oneOfinput objects asmax(fieldCost)instead ofsum(fieldCost). - Adjust circular input object traversal to stop on re-entry (assume a single recursion level).
- Add new
OneOfCostTestsand 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.
@oneOf in CostAnalysis
There was a problem hiding this comment.
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.
…CostVisitor.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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.
Summary of the changes (Less than 80 chars)
ModifyCostOptions/ costOptions (bool ConsiderOneOfandint AssumedRecursionDepthor so)Closes #9547 (in this specific format)
Closes #9548