Skip to content

fix: prevent context field scalar leaking into supergraph - #328

Merged
n1ru4l merged 1 commit into
graphql-hive:mainfrom
robbin-norberg-vcc:fix/context-field-value-leak
Sep 9, 2026
Merged

n1ru4l merged 1 commit into
graphql-hive:mainfrom
robbin-norberg-vcc:fix/context-field-value-leak

Conversation

@robbin-norberg-vcc

Copy link
Copy Markdown
Contributor

Summary

  • remove federation__ContextFieldValue from subgraph state with the other Federation built-in scalars
  • add a regression test for _service.sdl that declares the context field scalar
  • add a patch changeset

Without the cleanup, the composed supergraph assigns the built-in scalar to a subgraph. Apollo Router / @apollo/federation-internals then rejects extraction with:

Type federation__ContextFieldValue already exists in this schema

The regression reproduces on Federation v2.8 and v2.9 before the fix.

Follow-up to #326. This is a focused version of the scalar-leak fix identified in Uri Goldshtein's unmerged test/service-sdl-context-directives branch (457c0e8). Uri is credited as co-author.

Validation

  • pnpm typecheck
  • pnpm test --run --reporter=dot (7,201 passed, 25 skipped, 8 todo)
  • focused context test: 292 passed

@robbin-norberg-vcc
robbin-norberg-vcc marked this pull request as draft September 7, 2026 13:14
@kamilkisiela
kamilkisiela marked this pull request as ready for review September 9, 2026 08:21
Co-authored-by: Uri Goldshtein <uri.goldshtein@gmail.com>
@kamilkisiela
kamilkisiela force-pushed the fix/context-field-value-leak branch from 680c69a to 6f9f0f7 Compare September 9, 2026 08:21
@n1ru4l
n1ru4l merged commit 332a10a into graphql-hive:main Sep 9, 2026
5 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 9, 2026
n1ru4l pushed a commit that referenced this pull request Sep 9, 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.26.1

### Patch Changes

-
[#329](#329)
[`396442a`](396442a)
Thanks [@n1ru4l](https://github.com/n1ru4l)! - Preserve types referenced
by directive arguments when removing unreachable types from schema
contracts.

-
[#328](#328)
[`332a10a`](332a10a)
Thanks [@robbin-norberg-vcc](https://github.com/robbin-norberg-vcc)! -
Prevent `federation__ContextFieldValue` declared in a subgraph's
`_service.sdl` from leaking into the supergraph.

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