Skip to content

fix(validation): Correctly validate @key on interface implementations#241

Merged
n1ru4l merged 3 commits intomainfrom
kamil-fix-interface-key-on-interface
Jan 12, 2026
Merged

fix(validation): Correctly validate @key on interface implementations#241
n1ru4l merged 3 commits intomainfrom
kamil-fix-interface-key-on-interface

Conversation

@kamilkisiela
Copy link
Copy Markdown
Contributor

This PR fixes an issue in the subgraph validation logic for the @key directive on interfaces. Previously, the INTERFACE_KEY_NOT_ON_IMPLEMENTATION validation error was incorrectly triggered when an interface implemented another interface that had a @key directive.

The validation rule should only enforce that object types implementing an interface with @key also have the same @key. It should not apply to other interfaces that are part of the implementation chain.

error

Adds a test case to ensure that the INTERFACE_KEY_NOT_ON_IMPLEMENTATION
validation error is not incorrectly thrown for interfaces that implement
other interfaces with a @key directive.

The validation should only apply to object types implementing an
interface with @key, not other interfaces.
implementation

The validation for INTERFACE_KEY_NOT_ON_IMPLEMENTATION was incorrectly
checking all types that implement an interface with a @key directive,
including other interfaces.

This change ensures that the validation is only applied to object types,
which are the actual implementations that need to satisfy the @key
requirement.

This fixes cases where an interface implements another keyed interface,
which should not trigger a validation error.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kamilkisiela, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue in the subgraph validation process concerning the @key directive. It refines the logic to prevent an erroneous validation error from being triggered when an interface implements another interface that also uses the @key directive. The change ensures that this specific validation rule is correctly applied only to object types, aligning with the intended behavior of the Apollo Federation specification.

Highlights

  • Validation Fix: Corrected a bug in the @key directive validation logic that was incorrectly flagging interfaces implementing other interfaces with @key.
  • Targeted Validation: The validation rule for @key on interface implementations now correctly applies only to object types, not to interfaces implementing other interfaces.
  • New Test Case: Added a new test case to ensure that the INTERFACE_KEY_NOT_ON_IMPLEMENTATION error is not triggered in the corrected scenario.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@theguild/federation-composition 0.21.2-alpha-20260112140054-0b3232aebf1fe9bf25dbff40a219fc3a31ab0847 npm ↗︎ unpkg ↗︎

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug in the validation logic for the @key directive on interfaces. The fix correctly ensures that the validation rule INTERFACE_KEY_NOT_ON_IMPLEMENTATION is only applied to object types that implement an interface with @key, and not to other interfaces in the implementation chain. The change is simple, effective, and is accompanied by a new test case that properly validates the corrected behavior. The code quality is good, and I have no further suggestions for improvement.

Copy link
Copy Markdown
Contributor

@n1ru4l n1ru4l left a comment

Choose a reason for hiding this comment

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

legitto 💯

@kamilkisiela
Copy link
Copy Markdown
Contributor Author

mergitto, mi amore?

@n1ru4l n1ru4l merged commit c6e26ed into main Jan 12, 2026
4 checks passed
@n1ru4l n1ru4l deleted the kamil-fix-interface-key-on-interface branch January 12, 2026 14:06
@kamilkisiela
Copy link
Copy Markdown
Contributor Author

danke

@n1ru4l
Copy link
Copy Markdown
Contributor

n1ru4l commented Jan 12, 2026

全然いいよ

@kamilkisiela
Copy link
Copy Markdown
Contributor Author

Żabka

kamilkisiela pushed a commit that referenced this pull request Jan 12, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @theguild/federation-composition@0.21.2

### Patch Changes

-
[#241](#241)
[`c6e26ed`](c6e26ed)
Thanks [@kamilkisiela](https://github.com/kamilkisiela)! - Fixes a bug
in `@key` directive validation where an error was incorrectly reported
for interfaces implementing another interface with a `@key`. The
validation now correctly applies only to object types implementing the
interface.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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