Skip to content

fix: @requires with __typename on a union#248

Merged
n1ru4l merged 4 commits intomainfrom
kamil-requires-typename-union
Jan 16, 2026
Merged

fix: @requires with __typename on a union#248
n1ru4l merged 4 commits intomainfrom
kamil-requires-typename-union

Conversation

@kamilkisiela
Copy link
Copy Markdown
Contributor

No description provided.

@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 introduces a new test case to ensure the stability and correctness of GraphQL Federation composition logic. It specifically targets a scenario involving the @requires directive applied to a field that depends on __typename within a union type, verifying that such complex schema definitions are correctly handled during service composition.

Highlights

  • New Test Case for Federation Composition: A new test case has been added to validate the correct composition of federated schemas when the @requires directive is used in conjunction with __typename on a union type.
  • Validation of Union __typename in @requires: The test specifically confirms that a schema successfully composes when a field requires description { __typename ... on DescriptionLong { value } ... on DescriptionShort {value}} on a Product type, where description is a union, addressing a potential edge case.

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

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 adds a new test case to verify that @requires with __typename on a union type works correctly. The test itself is a good addition. My feedback includes suggestions to improve the test's clarity and maintainability by renaming the test, removing hardcoded versions, and fixing some formatting issues in the GraphQL schema strings.

rickbijkerk and others added 3 commits January 15, 2026 14:51
…ename of a union (#247)

Co-authored-by: Rick Bijkerk <rickbijkerk@bol.com>
Allow selecting __typename on union types by validating access to
each member type and returning the first member lacking access.
Continue to throw for non-__typename field selections on unions.
Update tests and use the version variable in federation spec URLs.
@kamilkisiela kamilkisiela force-pushed the kamil-requires-typename-union branch from b7d8b42 to 9555df1 Compare January 15, 2026 13:51
@kamilkisiela kamilkisiela marked this pull request as ready for review January 15, 2026 13:56
@kamilkisiela kamilkisiela requested a review from n1ru4l January 15, 2026 14:01
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.

Looking good but needs a changeset :finnadie:

@kamilkisiela
Copy link
Copy Markdown
Contributor Author

Looking good but needs a changeset :finnadie:

of course I forgot to push

Screenshot 2026-01-16 at 12 11 43

@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.3-alpha-20260116111315-b788100ad36f46d0bb0081ee852915930ab0d600 npm ↗︎ unpkg ↗︎

@n1ru4l n1ru4l merged commit 9535d50 into main Jan 16, 2026
4 checks passed
@n1ru4l n1ru4l deleted the kamil-requires-typename-union branch January 16, 2026 13:14
n1ru4l pushed a commit that referenced this pull request Jan 16, 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.3

### Patch Changes

-
[#248](#248)
[`9535d50`](9535d50)
Thanks [@kamilkisiela](https://github.com/kamilkisiela)! - Fix access
validation on union members when selecting `__typename` in `@requires`
directives.

The `@requires` directive validation rule (`AuthOnRequiresRule`) was not
checking authorization requirements for `__typename` selections on and
types. When `__typename` on a union type was selected, code would throw
an unexpected error.

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