Skip to content

fix: make propagated operation names unique#1256

Merged
ysmolski merged 4 commits intomasterfrom
yury/eng-7691-ensure-subgraph-operation-name-is-unique
Jul 31, 2025
Merged

fix: make propagated operation names unique#1256
ysmolski merged 4 commits intomasterfrom
yury/eng-7691-ensure-subgraph-operation-name-is-unique

Conversation

@ysmolski
Copy link
Copy Markdown
Contributor

@ysmolski ysmolski commented Jul 29, 2025

When operation names are sent to downstream subgraphs, send them in the following format:

$operationName__$subgraphName__$sequenceID

Also some comments were updated.

Summary by CodeRabbit

  • New Features

    • Operation names are now propagated to downstream subgraph fetches, improving traceability in federated GraphQL queries.
    • Fetch IDs are automatically appended to operation names in fetch trees, ensuring uniqueness across parallel and nested fetches.
  • Bug Fixes

    • None.
  • Documentation

    • Improved and clarified comments for several configuration fields and functions to enhance readability and understanding.
  • Tests

    • Updated federation test cases to reflect operation name propagation and fetch ID appending in fetch configurations.

Checklist

  • I have discussed my proposed changes in an issue and have received approval to proceed.
  • I have followed the coding standards of the project.
  • Tests or benchmarks have been added or updated.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 29, 2025

Walkthrough

This change introduces operation name propagation for downstream subgraph fetches in a GraphQL federation engine. It adds new fields and logic to carry, modify, and append operation names through the planning, fetch configuration, and post-processing stages. Associated tests and documentation are updated to reflect these enhancements, and a new post-processing component is introduced to append fetch IDs to operation names.

Changes

Cohort / File(s) Change Summary
GraphQL Datasource Operation Name Propagation
v2/pkg/engine/datasource/graphql_datasource/graphql_datasource.go
Adds propagatedOperationName to the planner, propagates operation names during planning, resets on document entry, and includes the name in fetch configuration.
Federation Test Updates for Operation Name
v2/pkg/engine/datasource/graphql_datasource/graphql_datasource_federation_test.go
Updates test fetch configurations to include explicit OperationName fields and unique operation name suffixes for each fetch.
Planner Documentation
v2/pkg/engine/plan/planner.go
Improves documentation for NewPlanner with punctuation and formatting changes.
Visitor Documentation
v2/pkg/engine/plan/visitor.go
Adds and refines comments for the Visitor struct and the configureObjectFetch method.
Postprocess Processor Enhancements
v2/pkg/engine/postprocess/postprocess.go
Adds appendFetchID processor and disableRewriteOpNames option; updates processing sequence to append fetch IDs after deduplication.
Fetch Configuration Field and Comments
v2/pkg/engine/resolve/fetch.go
Adds OperationName field to FetchConfiguration and expands field documentation.
Fetch ID Appender Processor
v2/pkg/engine/postprocess/fetch_id_appender.go
Introduces fetchIDAppender processor to append fetch IDs to operation names in fetch trees, with recursive traversal and update logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • The review requires understanding the propagation of operation names through planning, fetch configuration, and post-processing, as well as verifying correct integration in tests and new processor logic. The changes are moderately complex, with some new logic and multiple affected components.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 64da087 and 6af5027.

📒 Files selected for processing (1)
  • v2/pkg/engine/postprocess/fetch_id_appender.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • v2/pkg/engine/postprocess/fetch_id_appender.go
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch yury/eng-7691-ensure-subgraph-operation-name-is-unique

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ysmolski ysmolski force-pushed the yury/eng-7691-ensure-subgraph-operation-name-is-unique branch from c72a339 to 41771c5 Compare July 29, 2025 15:40
@ysmolski ysmolski changed the title fix: make unique propagated operation names fix: make propagated operation names unique Jul 29, 2025
@ysmolski ysmolski force-pushed the yury/eng-7691-ensure-subgraph-operation-name-is-unique branch from 41771c5 to 12336f8 Compare July 29, 2025 15:43
Comment thread v2/pkg/engine/datasource/graphql_datasource/graphql_datasource.go
Comment thread v2/pkg/engine/plan/planner.go Outdated
Comment thread v2/pkg/engine/postprocess/rewrite_op_names.go Outdated
Comment thread v2/pkg/engine/postprocess/postprocess.go Outdated
Comment thread v2/pkg/engine/resolve/fetch.go Outdated
Comment thread v2/pkg/engine/resolve/fetch.go Outdated
Comment thread v2/pkg/engine/resolve/fetch.go
@ysmolski ysmolski force-pushed the yury/eng-7691-ensure-subgraph-operation-name-is-unique branch from 12336f8 to 154cbb5 Compare July 30, 2025 08:24
When operation names are sent to downstream subgraphs, send
them in the following format:

    $operationName__$subgraphName__$sequenceID

Also some comments were updated.
@ysmolski ysmolski force-pushed the yury/eng-7691-ensure-subgraph-operation-name-is-unique branch from 154cbb5 to 181e48a Compare July 30, 2025 08:24
@ysmolski ysmolski requested a review from devsergiy July 30, 2025 08:25
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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12336f8 and 181e48a.

📒 Files selected for processing (7)
  • v2/pkg/engine/datasource/graphql_datasource/graphql_datasource.go (5 hunks)
  • v2/pkg/engine/datasource/graphql_datasource/graphql_datasource_federation_test.go (10 hunks)
  • v2/pkg/engine/plan/planner.go (1 hunks)
  • v2/pkg/engine/plan/visitor.go (2 hunks)
  • v2/pkg/engine/postprocess/fetch_id_appender.go (1 hunks)
  • v2/pkg/engine/postprocess/postprocess.go (4 hunks)
  • v2/pkg/engine/resolve/fetch.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • v2/pkg/engine/plan/planner.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • v2/pkg/engine/plan/visitor.go
  • v2/pkg/engine/datasource/graphql_datasource/graphql_datasource_federation_test.go
  • v2/pkg/engine/resolve/fetch.go
  • v2/pkg/engine/postprocess/postprocess.go
  • v2/pkg/engine/datasource/graphql_datasource/graphql_datasource.go
🧰 Additional context used
🧬 Code Graph Analysis (1)
v2/pkg/engine/postprocess/fetch_id_appender.go (2)
v2/pkg/engine/resolve/fetchtree.go (4)
  • FetchTreeNode (8-15)
  • FetchTreeNodeKindSingle (20-20)
  • FetchTreeNodeKindParallel (22-22)
  • FetchTreeNodeKindSequence (21-21)
v2/pkg/engine/resolve/fetch.go (2)
  • Fetch (20-25)
  • SingleFetch (89-96)
🔇 Additional comments (2)
v2/pkg/engine/postprocess/fetch_id_appender.go (2)

9-12: LGTM! Clean struct definition.

The fetchIDAppender struct is well-defined with a clear purpose and minimal state. The disable flag provides good control over the processor behavior.


14-19: LGTM! Proper entry point design.

The method correctly implements the disable check and proper delegation pattern. The early return when disabled is efficient.

Comment thread v2/pkg/engine/postprocess/fetch_id_appender.go
Comment thread v2/pkg/engine/postprocess/fetch_id_appender.go
@ysmolski ysmolski requested a review from StarpTech July 30, 2025 08:38
Copy link
Copy Markdown
Collaborator

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

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

LGTM

@ysmolski ysmolski merged commit c2be87e into master Jul 31, 2025
10 checks passed
@ysmolski ysmolski deleted the yury/eng-7691-ensure-subgraph-operation-name-is-unique branch July 31, 2025 11:35
ysmolski pushed a commit that referenced this pull request Jul 31, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.0.0-rc.215](v2.0.0-rc.214...v2.0.0-rc.215)
(2025-07-31)


### Bug Fixes

* make propagated operation names unique
([#1256](#1256))
([c2be87e](c2be87e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
  * Resolved an issue to ensure propagated operation names are unique.

* **Documentation**
  * Added a changelog entry for version 2.0.0-rc.215.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

3 participants