Skip to content

feat: support dot-path in slicingArguments#1485

Open
ysmolski wants to merge 4 commits intomasterfrom
yury/eng-9338-router-support-dot-path-in-slicingarguments
Open

feat: support dot-path in slicingArguments#1485
ysmolski wants to merge 4 commits intomasterfrom
yury/eng-9338-router-support-dot-path-in-slicingarguments

Conversation

@ysmolski
Copy link
Copy Markdown
Contributor

@ysmolski ysmolski commented May 5, 2026

This PR enables the use of dot-path slicing arguments in a listSize directives. If an operation uses deeply nested input objects, then user can specify the deeply nested int value to be used as an estimation of the returned list size:

input PaginationInput {
  first: Int
  after: String
}

input SearchInput {
  pagination: PaginationInput
  query: String
}

type Query {
  search(input: SearchInput!): [Book]
       @listSize(slicingArguments: ["input.pagination.first"])
}

This PR enables the use of dot-path slicing arguments in a listSize
directives. If an operation uses deeply nested input objects, then user
can specify the deeply nested int value to be used as an estimation of
the returned list size:

    input PaginationInput {
      first: Int
      after: String
    }

    input SearchInput {
      pagination: PaginationInput
      query: String
    }

    type Query {
      search(input: SearchInput!): [Book]
	@listsize(slicingArguments: ["input.pagination.first"])
    }
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

Adds support for dot-path slicing arguments (e.g., "pagination.limit.first") so the cost calculator can extract integer slice sizes from nested input-object variables. Implements a helper to traverse variable JSON, updates multiplier and validation logic, and expands tests with dot-path literal/variable and null/missing cases.

Changes

Dot-Path Slicing Argument Support

Layer / File(s) Summary
Data Shape / Test Schema
execution/engine/execution_engine_cost_test.go
Adds SInput/PInput input types and Query.search(input: SInput) to exercise dot-path slicing like input.pagination.first. Updates rootNodes and test field wiring.
Helper Addition
v2/pkg/engine/plan/cost.go
Adds ArgumentInfo.slicingArgumentIntValue(path []string, variables *astjson.Value) (int, bool) to traverse variable JSON along a dot-path and return an integer leaf.
Core Cost Logic
v2/pkg/engine/plan/cost.go
Refactors FieldListSize.multiplier to support dot-path slicing args by resolving root argument and extracting nested integer values; updates comment for SlicingArguments.
Validation Wiring
v2/pkg/engine/plan/cost.go
Enhances CostTreeNode.validateSliceArguments to count dot-path slicing args (using the new helper) when RequireOneSlicingArgument is enabled.
Tests / Assertions
execution/engine/execution_engine_cost_test.go
Extends test cases: dot-path literals, nested-input variables, null/missing-leaf behaviors, and enforcement of RequireOneSlicingArgument with precise error-message assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • wundergraph/graphql-go-tools#1461: Touches cost-calculation and ArgumentInfo handling for nested/input-object argument values; closely related to the dot-path and recursive input traversal changes.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: support dot-path in slicingArguments' directly and clearly describes the main feature being added - support for dot-path syntax in slicing arguments.
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 The PR description directly aligns with the changeset, clearly explaining the feature to support dot-path slicing arguments in listSize directives with a concrete example.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yury/eng-9338-router-support-dot-path-in-slicingarguments

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
execution/engine/execution_engine_cost_test.go (1)

1477-1565: ⚡ Quick win

Add a regression for omitted $input variable (empty variables object).

Current required dot-path invalid tests cover missing intermediate and null leaf, but not the root variable being absent ({}), which is a distinct path worth locking down.

🧪 Suggested test addition
+		t.Run("required dot-path slicing argument with omitted root variable is invalid", runWithAndCompareError(
+			ExecutionEngineTestCase{
+				schema: schemaSlicing,
+				operation: func(t *testing.T) graphql.Request {
+					return graphql.Request{
+						Query: `query NestedInput($input: SInput) {
+							  search(input: $input) { id }
+							}`,
+						Variables: []byte(`{}`),
+					}
+				},
+				dataSources: []plan.DataSource{
+					// same datasource setup as other required-dot-path invalid cases
+				},
+				fields: fieldConfig,
+			},
+			"external: field 'Query.search' requires exactly one slicing argument, but none was provided, locations: [], path: [search]",
+			computeCosts(),
+		))
🤖 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 `@execution/engine/execution_engine_cost_test.go` around lines 1477 - 1565, Add
a regression test that mirrors the two existing "required dot-path slicing
argument missing" cases but uses an empty variables object (Variables:
[]byte(`{}`)) so the root $input variable is omitted; update the suite by adding
a new t.Run using runWithAndCompareError with ExecutionEngineTestCase
referencing schemaSlicing, the same mustGraphqlDataSourceConfiguration and
DataSourceCostConfig (SlicingArguments: []string{"input.pagination.first"},
RequireOneSlicingArgument: true) and assert the same error string "external:
field 'Query.search' requires exactly one slicing argument, but none was
provided, locations: [], path: [search]" while keeping computeCosts() as the
executor.
🤖 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.

Nitpick comments:
In `@execution/engine/execution_engine_cost_test.go`:
- Around line 1477-1565: Add a regression test that mirrors the two existing
"required dot-path slicing argument missing" cases but uses an empty variables
object (Variables: []byte(`{}`)) so the root $input variable is omitted; update
the suite by adding a new t.Run using runWithAndCompareError with
ExecutionEngineTestCase referencing schemaSlicing, the same
mustGraphqlDataSourceConfiguration and DataSourceCostConfig (SlicingArguments:
[]string{"input.pagination.first"}, RequireOneSlicingArgument: true) and assert
the same error string "external: field 'Query.search' requires exactly one
slicing argument, but none was provided, locations: [], path: [search]" while
keeping computeCosts() as the executor.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a41d237b-36e1-4494-bb19-7192b052eb64

📥 Commits

Reviewing files that changed from the base of the PR and between cc65e4e and 3cdb077.

📒 Files selected for processing (2)
  • execution/engine/execution_engine_cost_test.go
  • v2/pkg/engine/plan/cost.go

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@execution/engine/execution_engine_cost_test.go`:
- Around line 1431-1609: The failing test "required dot-path slicing argument
missing leaf is invalid" currently sends Variables with
`"pagination":{"first":null}` which doesn't exercise a truly absent leaf; update
the operation function for that test (the graphql.Request Variables payload in
the test case inside t.Run "required dot-path slicing argument missing leaf is
invalid") to use an omitted leaf such as `"pagination":{}` (e.g.
`{"input":{"pagination":{},"query":"abc"}}`) so the dot-path walker sees the key
missing rather than null; keep the rest of the test (dataSources, CostConfig,
expected error) unchanged.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 08057027-7aaf-4581-a204-78b5d7a39297

📥 Commits

Reviewing files that changed from the base of the PR and between 3cdb077 and 3fd9856.

📒 Files selected for processing (1)
  • execution/engine/execution_engine_cost_test.go

Comment thread execution/engine/execution_engine_cost_test.go
ysmolski added 2 commits May 6, 2026 15:42
… yury/eng-9338-router-support-dot-path-in-slicingarguments
… yury/eng-9338-router-support-dot-path-in-slicingarguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant