Skip to content

chore: subgraph fields retain info about inherited directives#2013

Merged
Aenimus merged 2 commits intomainfrom
david/eng-7494-fields-retain-directive-inheritance-info
Jul 3, 2025
Merged

chore: subgraph fields retain info about inherited directives#2013
Aenimus merged 2 commits intomainfrom
david/eng-7494-fields-retain-directive-inheritance-info

Conversation

@Aenimus
Copy link
Copy Markdown
Member

@Aenimus Aenimus commented Jul 3, 2025

Summary by CodeRabbit

  • New Features
    • Added support for tracking inherited directive names on fields, enhancing metadata visibility for users working with federated schemas.

Checklist

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 3, 2025

Walkthrough

A new property, inheritedDirectiveNames of type Set<string>, was added to the FieldData type and is now populated in both the federation and normalization factories. The normalization factory updates methods to track and assign inherited directive names, and both factories ensure this property is included in their field data objects.

Changes

Files/Areas Changed Change Summary
composition/src/schema-building/types.ts Added inheritedDirectiveNames: Set<string> property to FieldData type definition.
composition/src/v1/federation/federation-factory.ts Updated copyFieldData to initialize inheritedDirectiveNames as an empty set in returned object.
composition/src/v1/normalization/normalization-factory.ts Updated addInheritedDirectivesToFieldData and addFieldDataByNode to accept and set inheritedDirectiveNames; added logic to conditionally add directives and update the set.
composition/src/v1/normalization/walkers.ts Added local inheritedDirectiveNames set in upsertParentsAndChildren visitor; passed it to normalization factory methods.

📜 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 fd4ea40 and d927d52.

📒 Files selected for processing (3)
  • composition/src/v1/federation/federation-factory.ts (1 hunks)
  • composition/src/v1/normalization/normalization-factory.ts (3 hunks)
  • composition/src/v1/normalization/walkers.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • composition/src/v1/federation/federation-factory.ts
  • composition/src/v1/normalization/normalization-factory.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
composition/src/v1/normalization/walkers.ts (1)
composition/src/schema-building/utils.ts (1)
  • isParentDataInterfaceType (260-262)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Analyze (go)
  • GitHub Check: build_push_image
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: build_test
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: image_scan
  • GitHub Check: build_push_image
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: integration_test (./events)
  • GitHub Check: build_test
🔇 Additional comments (3)
composition/src/v1/normalization/walkers.ts (3)

363-363: LGTM: Proper initialization of inherited directive names tracking.

The inheritedDirectiveNames variable is correctly initialized as an empty Set<string>() to track inherited directive names for the current field.


366-366: LGTM: Correct method signature update.

The addInheritedDirectivesToFieldData method call now properly includes the inheritedDirectiveNames parameter, allowing the method to populate the set with inherited directive names.


376-376: LGTM: Proper propagation of inherited directive names.

The addFieldDataByNode method call correctly includes the inheritedDirectiveNames parameter, ensuring that the populated set of inherited directive names is passed to the field data creation process.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 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.

@Aenimus Aenimus enabled auto-merge (squash) July 3, 2025 16:53
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 3, 2025

Router image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-c9d5649e6ca03f0a4a4dc8937737bd20f208b0e7

@Aenimus Aenimus changed the title chore: fields retain info about which directives they inherited chore: subgraph fields retain info about inherited directives Jul 3, 2025
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

🧹 Nitpick comments (2)
composition/src/schema-building/types.ts (1)

102-102: Good addition, but consider adding documentation.

The inheritedDirectiveNames property is well-designed using Set<string> to avoid duplicates and follows the existing naming conventions. However, consider adding a JSDoc comment to explain its purpose and usage.

+ // Set of directive names inherited from the parent object type
  inheritedDirectiveNames: Set<string>;
composition/src/v1/normalization/normalization-factory.ts (1)

1032-1041: LGTM! Clean implementation for tracking inherited directives.

The method correctly identifies which directives are inherited from the parent object based on the current context flags. The logic is straightforward and the return type matches the expected Set<string>.

Consider adding JSDoc documentation to clarify the inheritance rules:

+  /**
+   * Returns the set of directive names that fields inherit from their parent object.
+   * Fields inherit @external if the parent object is external, and @shareable if the parent object is shareable.
+   */
   getInheritedDirectiveNames(): Set<string> {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f47a87 and fd4ea40.

📒 Files selected for processing (3)
  • composition/src/schema-building/types.ts (1 hunks)
  • composition/src/v1/federation/federation-factory.ts (1 hunks)
  • composition/src/v1/normalization/normalization-factory.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
composition/src/v1/normalization/normalization-factory.ts (1)
composition/src/utils/string-constants.ts (2)
  • EXTERNAL (42-42)
  • SHAREABLE (127-127)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: integration_test (./events)
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: build_push_image
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: image_scan
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: build_test
  • GitHub Check: build_push_image
🔇 Additional comments (1)
composition/src/v1/normalization/normalization-factory.ts (1)

1102-1102: Good integration of inherited directive tracking.

The inheritedDirectiveNames property is correctly populated using the new helper method, ensuring each field retains information about which directives it inherited from its parent object.

Comment thread composition/src/v1/federation/federation-factory.ts
@Aenimus Aenimus disabled auto-merge July 3, 2025 16:58
@Aenimus Aenimus merged commit e4581bb into main Jul 3, 2025
40 of 44 checks passed
@Aenimus Aenimus deleted the david/eng-7494-fields-retain-directive-inheritance-info branch July 3, 2025 17:26
@coderabbitai coderabbitai Bot mentioned this pull request Sep 16, 2025
5 tasks
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.

2 participants