Repository navigation
fix(mercurius): require the gateway release that resolves union fields - #4190
Merged
Merged
Conversation
@mercuriusjs/gateway before 5.1.0 never fetched the _entities of union members that live in another subgraph when the union is an object field type, so such fields failed with "Cannot return null for non-nullable field". 5.1.0 fixed it (mercurius-js/mercurius-gateway#122). Raise the peer floor to ^5.1.0 and add a regression test for field- and query-level unions of entity references. Closes #2165
This was referenced Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
PR Type
What is the current behavior?
#2165: with the Mercurius gateway, a union of entity references used as an object field type (e.g.
User.favoriteItem: FavoriteItemUnionwhose members live in another subgraph) fails withCannot return null for non-nullable field Song.title., while the same union as a Query return type works. The cause was the gateway's query planner, which never sent the_entitiesfetch for such members. It was fixed upstream in mercurius-js/mercurius-gateway#122, released in@mercuriusjs/gateway5.1.0. The peer range here still allows^5.0.0.Issue Number: #2165
What is the new behavior?
@mercuriusjs/gatewaypeer range:^5.1.0(it stays optional; the devDependency is already 5.2.0).tests/e2e/federated-union-field.spec.ts: a code-first users subgraph withSong/Movieentity stubs in acreateUnionTypeunion, used as an object field (directly and via@ResolveField) and as a Query return type, composed by the Mercurius gateway with a media subgraph that resolves the references. It passes with 5.1.0+ and fails with 5.0.0 with the error from the issue.Closes #2165
Does this PR introduce a breaking change?
Raising the peer floor is formally semver-major, but 5.0.x can't resolve these fields.