Skip to content

Fix @join__field emission for Fed v1 @external and @override+ @requires edge cases#282

Merged
kamilkisiela merged 5 commits intomainfrom
kamilkisiela-patch-1
Mar 16, 2026
Merged

Fix @join__field emission for Fed v1 @external and @override+ @requires edge cases#282
kamilkisiela merged 5 commits intomainfrom
kamilkisiela-patch-1

Conversation

@kamilkisiela
Copy link
Copy Markdown
Contributor

@kamilkisiela kamilkisiela commented Mar 10, 2026

Reproduced issues caused by #267 and added a few test cases to showcase differences between Apollo's supergraph and ours.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 expands the test suite for Apollo Federation v2 composition, focusing on the accurate generation of @join__field directives. It specifically addresses scenarios involving object type extensions where @key fields are marked as @external, and when @external fields are further utilized with the @requires directive. These additions bolster the reliability of supergraph schema composition under advanced federation patterns.

Highlights

  • @join__field testing: Added new test cases to verify the correct generation and retention of @join__field directives in the composed supergraph SDL.
  • @key and @external interaction: Introduced a test case specifically for object type extensions where the @key directive references fields marked as @external.
  • @requires directive validation: Included a test to ensure @join__field directives are correctly handled for @external fields that are also used with the @requires directive.
Changelog
  • tests/composition.spec.ts
    • Added two new test cases for @join__field directive behavior.
    • Verified correct supergraph SDL output for object type extensions with @key and @external fields.
    • Ensured proper handling of @join__field when @external fields are used with @requires.
Activity
  • No human activity has occurred on this pull request yet.
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.

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 introduces two new test cases to composition.spec.ts to enhance test coverage for @join__field directive composition, specifically for object type extensions. The tests cover scenarios where key fields are marked as @external and where other external fields are utilized in @requires directives. The added tests are clear, target specific edge cases, and the assertions appear correct based on the expected composition behavior. The changes are a good addition to the test suite.

…@requires` edge cases (#284)

This PR corrects supergraph's `@join__field` emission in a few edge
cases where emitted metadata could be incorrect or redundant.

- Use subgraph-local key usage when deciding whether to drop Federation
v1 `@join__field(external:true)`
- Avoid emitting redundant `@join__field(external: true)` metadata when
a field is only required through overridden paths
- Tighten `@join__field` emission around `@override` and interface type
fields.

This aligns emitted supergraph metadata with Apollo Gateway's
requirements.
Added Apollo supergraph validation in testkit to catch compatibility
regressions earlier.
@kamilkisiela kamilkisiela force-pushed the kamilkisiela-patch-1 branch from 2103359 to de2d7db Compare March 16, 2026 14:21
@kamilkisiela kamilkisiela changed the title Add tests for @join__field in object type extensions Fix @join__field emission for Fed v1 @external and @override+ @requires edge cases Mar 16, 2026
@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.22.1-alpha-20260316142152-de2d7db5e37e6d9d05ce7b77f1481eb263dfb2df npm ↗︎ unpkg ↗︎

@kamilkisiela kamilkisiela merged commit e507fdd into main Mar 16, 2026
4 checks passed
@kamilkisiela kamilkisiela deleted the kamilkisiela-patch-1 branch March 16, 2026 14:51
n1ru4l pushed a commit that referenced this pull request Mar 17, 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.22.1

### Patch Changes

-
[#291](#291)
[`ec0ef84`](ec0ef84)
Thanks [@jdolle](https://github.com/jdolle)! - Support "file:" protocol
and non-RFC 3986 in imported "link" url argument

-
[#282](#282)
[`e507fdd`](e507fdd)
Thanks [@kamilkisiela](https://github.com/kamilkisiela)! - Fix
supergraph `@join__field` emission for Federation v1 `@external` fields
and improve override/requires edge-case handling.
- Drop Federation v1 `@join__field(external: true)` fields based on key
usage in the subgraph instead of aggregated field key usage across
subgraphs.
- Avoid emitting redundant `@join__field(external: true)` metadata when
a field is only required through overridden paths.
- Tighten `@join__field` emission around `@override` and interface type
fields.

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.

1 participant