Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThis PR extends the ChangesNested-Path Slicing Arguments Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2801 +/- ##
==========================================
+ Coverage 46.23% 46.84% +0.61%
==========================================
Files 1080 1100 +20
Lines 144704 149292 +4588
Branches 9247 10269 +1022
==========================================
+ Hits 66897 69930 +3033
- Misses 76077 77592 +1515
- Partials 1730 1770 +40
🚀 New features to boost your workflow:
|
Router-nonroot image scan passed✅ No security vulnerabilities found in image: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@composition/src/v1/normalization/normalization-factory.ts`:
- Around line 2665-2670: The code currently uses only the first segment
(firstSegment) when reporting a missing root argument, which loses the full SDL
path; change the error creation to pass the full configured argument path (e.g.,
the original slicing argument string or segments.join(".")/slicingArg) into
listSizeInvalidSlicingArgumentErrorMessage instead of firstSegment so the
diagnostic shows the full path; update the call site where argData is checked
(the block referencing segments, firstSegment, argData, errorMessages, and
listSizeInvalidSlicingArgumentErrorMessage) to supply the full path string and
ensure any helpers expecting just the name are adjusted to accept the dotted
path.
🪄 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: 3479e173-63e7-462f-aee0-ad2ba57ad429
📒 Files selected for processing (4)
composition-go/index.global.jscomposition/src/errors/errors.tscomposition/src/v1/normalization/normalization-factory.tscomposition/tests/v1/directives/listSize.test.ts
c9873ed to
6bf922d
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
composition/src/errors/errors.ts (1)
1789-1797:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winGeneralize the non-
Intmessage for nested paths.With dot-path support, this can now describe a nested input field rather than a top-level argument, so the current
"references an argument of type"wording is inaccurate for valid new inputs likeinput.pagination.first.Suggested wording
export function listSizeSlicingArgumentNotIntErrorMessage( directiveCoords: DirectiveArgumentCoords, argumentName: ArgumentName, actualType: TypeName, ): string { return ( - ` The "slicingArguments" value "${argumentName}" on "${directiveCoords}" references an argument of type` + + ` The "slicingArguments" value "${argumentName}" on "${directiveCoords}" references a value of type` + ` "${actualType}", but slicing arguments must be of type "Int" or "Int!".` ); }🤖 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 `@composition/src/errors/errors.ts` around lines 1789 - 1797, The error string in listSizeSlicingArgumentNotIntErrorMessage is specific to top-level arguments ("references an argument of type") but must cover nested dot-paths (input fields) as well; update the returned message to use a generalized phrase like "references a value of type" or "references an input value of type" so the function listSizeSlicingArgumentNotIntErrorMessage(directiveCoords, argumentName, actualType) correctly describes both arguments and nested input fields when actualType is not Int/Int!.
🧹 Nitpick comments (2)
composition/src/v1/normalization/normalization-factory.ts (1)
2669-2670: Gate dottedslicingArgumentson router support.These paths are now serialized into
costs.listSizesunchanged. If composition ships before router support, older routers can ignore them and start rejecting requests for fields that still require a slicing argument. Consider enforcing this with a compatibility check, feature gate, or rollout guard instead of relying on release ordering alone.Also applies to: 2758-2759
🤖 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 `@composition/src/v1/normalization/normalization-factory.ts` around lines 2669 - 2670, Paths are being unconditionally added to listSizeConfig.slicingArguments and slicingArgChainByPath (slicingArgPath / slicingArgChainByPath), which causes costs.listSizes to serialize slicing arguments even when downstream routers may not support them; add a compatibility gate before pushing/setting these values: detect router support (e.g., via a feature flag or a runtime check like routerSupportsSlicingArgs(costs) or enableRouterSlicingArgs) and only call listSizeConfig.slicingArguments.push(slicingArgPath) and slicingArgChainByPath.set(slicingArgPath, chain) when the gate returns true; apply the same guarded change for the identical block around lines where slicing arguments are added (the other occurrence at the reported range 2758-2759).composition/tests/v1/directives/listSize.test.ts (1)
655-676: ⚡ Quick winAdd a normalized-SDL assertion for a nested-path happy path.
The new success cases only verify
costs.listSizes, so a regression in emitted composition output would still pass. Please mirror the earlier normalization checks with at least one assertion thatschemaToSortedNormalizedString(schema)preserves@listSize(slicingArguments: ["input.pagination.first"])—ideally also for the mixed flat+nested case.🤖 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 `@composition/tests/v1/directives/listSize.test.ts` around lines 655 - 676, Add assertions that verify the normalized SDL still emits the `@listSize` directive with the nested slicingArguments: after the existing checks in the "nested-path slicingArguments tests" (in the tests using subgraphWithDeepNestedSlicingArg and subgraphWithMixedSlicingArgs / ROUTER_COMPATIBILITY_VERSION_ONE), call schemaToSortedNormalizedString(schema) on the returned schema and assert the string contains '@listSize(slicingArguments: ["input.pagination.first"])' for the deep-nested case and contains the corresponding combined form (e.g. '@listSize(slicingArguments: ["limit","input.pagination.first"])') for the mixed case; keep these assertions alongside the existing checks that reference costs.listSizes.get('Query.search') so the test covers both runtime cost normalization and the emitted normalized SDL.
🤖 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.
Outside diff comments:
In `@composition/src/errors/errors.ts`:
- Around line 1789-1797: The error string in
listSizeSlicingArgumentNotIntErrorMessage is specific to top-level arguments
("references an argument of type") but must cover nested dot-paths (input
fields) as well; update the returned message to use a generalized phrase like
"references a value of type" or "references an input value of type" so the
function listSizeSlicingArgumentNotIntErrorMessage(directiveCoords,
argumentName, actualType) correctly describes both arguments and nested input
fields when actualType is not Int/Int!.
---
Nitpick comments:
In `@composition/src/v1/normalization/normalization-factory.ts`:
- Around line 2669-2670: Paths are being unconditionally added to
listSizeConfig.slicingArguments and slicingArgChainByPath (slicingArgPath /
slicingArgChainByPath), which causes costs.listSizes to serialize slicing
arguments even when downstream routers may not support them; add a compatibility
gate before pushing/setting these values: detect router support (e.g., via a
feature flag or a runtime check like routerSupportsSlicingArgs(costs) or
enableRouterSlicingArgs) and only call
listSizeConfig.slicingArguments.push(slicingArgPath) and
slicingArgChainByPath.set(slicingArgPath, chain) when the gate returns true;
apply the same guarded change for the identical block around lines where slicing
arguments are added (the other occurrence at the reported range 2758-2759).
In `@composition/tests/v1/directives/listSize.test.ts`:
- Around line 655-676: Add assertions that verify the normalized SDL still emits
the `@listSize` directive with the nested slicingArguments: after the existing
checks in the "nested-path slicingArguments tests" (in the tests using
subgraphWithDeepNestedSlicingArg and subgraphWithMixedSlicingArgs /
ROUTER_COMPATIBILITY_VERSION_ONE), call schemaToSortedNormalizedString(schema)
on the returned schema and assert the string contains
'@listSize(slicingArguments: ["input.pagination.first"])' for the deep-nested
case and contains the corresponding combined form (e.g.
'@listSize(slicingArguments: ["limit","input.pagination.first"])') for the mixed
case; keep these assertions alongside the existing checks that reference
costs.listSizes.get('Query.search') so the test covers both runtime cost
normalization and the emitted normalized SDL.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: af468a49-15fd-4b85-baa3-b5b70aea3fd3
📒 Files selected for processing (4)
composition-go/index.global.jscomposition/src/errors/errors.tscomposition/src/v1/normalization/normalization-factory.tscomposition/tests/v1/directives/listSize.test.ts
…8-router-support-dot-path-in-slicingarguments
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@composition/src/v1/normalization/normalization-factory.ts`:
- Around line 2754-2758: The current check on listSizeConfig.slicingArguments
uses slicingArgChainByPath.get(...) and rejects the path if chain.some(node =>
node.defaultValue) — instead, for each node in the chain that has a defaultValue
you must try to resolve the remainder of the dotted path through that node's
defaultValue AST and only treat it as a blocking default if that resolution
actually yields a leaf value for the targeted slicing argument; if the ancestor
defaultValue does not contain/resolve the remaining path segments, it should not
trigger listSizeAssumedSizeSlicingArgDefaultErrorMessage(directiveCoords,
slicingArgPath). Implement a resolver that walks the defaultValue AST along the
tail path from that node and only push the error when the resolved value is
present (or explicitly null/defined per current semantics).
- Around line 2625-2639: The current branch conflates "undefined parent type"
and "parent type not an input object", causing a duplicate segmentNotInputObject
error; update the logic around
parentDefinitionDataByTypeName.get(current.namedTypeName) so that: if
unwrapped.kind === Kind.LIST_TYPE keep the existing error; else if
parentTypeData is undefined set isPathInvalid = true but do NOT call
listSizeSlicingArgumentSegmentNotInputObjectErrorMessage; else if
parentTypeData.kind !== Kind.INPUT_OBJECT_TYPE_DEFINITION then push the
listSizeSlicingArgumentSegmentNotInputObjectErrorMessage and set isPathInvalid =
true. Reference symbols: parentDefinitionDataByTypeName, current, unwrapped,
Kind.LIST_TYPE, parentTypeData.kind, Kind.INPUT_OBJECT_TYPE_DEFINITION,
listSizeSlicingArgumentSegmentNotInputObjectErrorMessage, isPathInvalid.
🪄 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: 8f90da03-7acc-4721-84d6-ec00d8609a7f
📒 Files selected for processing (1)
composition/src/v1/normalization/normalization-factory.ts
…8-router-support-dot-path-in-slicingarguments
When the list size comes from an argument nested in an input object,
use a dot-separated path in slicingArguments:
This PR contains composition and router changes Composition passes slices argiments in the the same
fields, but this time it parses and validates the dot-path for each slicingArgument.
One small caveat. We should release this in the composition after the router has support for the same feature.
Otherwise, if a user composes config with dot-path slicingArguments and feeds to the router without support of it, then router will throw the error "400" for queries on fields having
requireOneSlicingArgument == true. It is because router will ignore such dot-path fields and validation won't pass. Right now it is impossible to release router part first because it depends on the changes in composition so I will release it at the same time.I will make a note on the documentation about these features requiring specific versions of composition and router.
Summary by CodeRabbit