graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

fix: support linked, repeatable, federation directives

Open jdolle opened this issue 5 months ago • 3 comments

Description

Adds support for known repeatable federation directives without requiring they be defined in the SDL.

Previously, mergeTypeDefs used the directive definition node to check if a directive was repeatable. This is an issue with Federation because @link can be used without specifying what is being imported for the default federation links. Rather than add the definitions, which may become stale, I made note of specifically which directives with federation are repeatable. This list is short and is unlikely to change frequently.

I also adjusted the mergeTypeDefs logic for repeatable directives. If they are repeatable, then they are only merged if all the arguments match.

Related:

  • https://github.com/ardatan/graphql-tools/issues/6505
  • https://github.com/ardatan/graphql-tools/issues/4338
  • https://github.com/ardatan/graphql-tools/issues/4339
  • https://github.com/ardatan/graphql-tools/issues/6929

Type of change

Please delete options that are not relevant.

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

See test files.

Checklist:

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

jdolle avatar Jun 16 '25 21:06 jdolle