Skip to content

Handle federation v2 links #7229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2025
Merged

Handle federation v2 links #7229

merged 2 commits into from
Jun 2, 2025

Conversation

jdolle
Copy link
Collaborator

@jdolle jdolle commented May 28, 2025

Description

Some directives for GraphQL Federation are missing from the list of built-ins. This is because the current setup is intended to only handle federation 1.
Federation 2 requires handling aliases etc.

This modifies the logic to handle links per federation 2 definition.

Related #7224

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@jdolle jdolle requested a review from ardatan May 28, 2025 17:22
@jdolle jdolle self-assigned this May 28, 2025
Copy link

changeset-bot bot commented May 28, 2025

🦋 Changeset detected

Latest commit: 29ac2ef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@graphql-tools/import Patch
@graphql-tools/graphql-file-loader Patch
@graphql-tools/node-require Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@jdolle jdolle force-pushed the federation-directives-builtin branch from 74187f6 to 8447a90 Compare May 28, 2025 20:29

const builtinTypes = ['String', 'Float', 'Int', 'Boolean', 'ID', 'Upload'];

const federationV1Directives = ['key', 'provides', 'requires', 'external'];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed link from this list per our discussion

@jdolle jdolle changed the title Add all remaining federation directives to list of built-ins Handle federation v2 links May 28, 2025
coderabbitai[bot]

This comment was marked as resolved.

.filter(l => ![linkUrl, federationUrl].includes(l.identity))
.flatMap(l => l.imports.map(i => i.as ?? i.name));
for (const namedImport of imported) {
addDefinition(namedImport);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I recall that, thankfully, for whatever reason, non-federation packages dont support the namespaced import syntax.

@jdolle
Copy link
Collaborator Author

jdolle commented May 29, 2025

One consideration with this change is that I am leaving the builtins for federation v1 directives.
I think ideally we should determine if any of the documents use federation v2 and if so, not include the v1 directives in the list of builtins.
Let me know if that should be part of this same change.

@jdolle jdolle merged commit a824120 into master Jun 2, 2025
1 check passed
@jdolle jdolle deleted the federation-directives-builtin branch June 2, 2025 15:12
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