Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces federation support for shared entities with external key fields. It adds a new test suite validating federation scenarios where key fields exist only in ExternalFieldNames rather than regular FieldNames, implements a new interface method to check for non-external fields in datasources, and updates key-field visitor logic to correctly treat keys as non-external when datasources actively resolve entities. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
|
Close it because it's a composition error. |
Summary
Fixes query planning failure (500 error) when a federated query references a shared entity whose @key
field is marked @external in one subgraph.
Example: A CartBundleProduct entity exists in two subgraphs. The cart subgraph owns fields like name
and category but marks the key field code as @external. The products subgraph owns code. Querying
bundleProducts { code name } through the cart subgraph would fail with:
Root Cause
Newer federation composition puts @external key fields only in ExternalFieldNames (not in both
FieldNames and ExternalFieldNames like older composition did). This broke two assumptions in the
planner:
fields relied on the field being in both FieldNames and ExternalFieldNames. With the field only in
ExternalFieldNames, the key was incorrectly treated as external, preventing the cart subgraph from
being a key "source." This broke the jump graph so no datasource could resolve the field.
#1, thecart subgraph still didn't suggest the code field. When the visitor converted an external field to
non-external (via notExternalKeyPaths), it cleared isExternal but the field had no other qualifying
flag (hasRootNode, hasChildNode, isProvided were all false). So no suggestion was created and the
planner routed code to the products subgraph via entity resolution — generating a malformed upstream
query.
Fix
Three changes:
actively resolves a type (has regular, non-external fields for it) vs. being a stub with only external
key fields.
that entity type, treat the key as non-external. The datasource actively resolves this entity, so it
can provide the key field in its response.
(because it's a key field), promote its external root/child node status to regular root/child status.
This ensures a field suggestion is actually created, so the planner can route the field to the correct
datasource.
Test plan
CodeRabbit
Summary by CodeRabbit
Release Notes
Tests
Improvements
Checklist