Conversation
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.
resolves #10464
also resolves an issue where linksMode asserted too aggressively for sync belongsTo relationships.
Summary of Changes
1. Overall Purpose/Goal
This branch fixes how
getRemoteRelationshiphandles sync belongsTo relationships, particularly in linksMode. The changes ensure proper distinction between "never set" (undefined), "explicitly null", and "has value" relationship states, while also allowing mutations of sync belongsTo fields in Polaris mode.2. Key Files Modified
Core Logic Changes:
warp-drive-packages/core/src/graph/-private/edges/resource.ts- Fixed remote relationship data retrieval logicwarp-drive-packages/core/src/graph/-private/operations/replace-related-record.ts- Separated remote vs localhasReceivedDatatrackingwarp-drive-packages/core/src/graph/-private/operations/update-relationship.ts- Removed automatic initialization of unset relationshipswarp-drive-packages/core/src/reactive/-private/kind/belongs-to-field.ts- Added support for editing sync belongsTo in Polaris modewarp-drive-packages/json-api/src/-private/validate-document-fields.ts- Improved validation logic for sync vs async linksMode relationshipsInfrastructure:
warp-drive-packages/core/src/graph/-private/-state.ts- Added debug logging for state trackingwarp-drive-packages/core/src/reactive/-private/schema.ts- Added$keyidentifier field to schemas, enhanced documentationTests:
tests/json-api/tests/integration/cache/cache.get-remote-relationship-test.ts- New file with comprehensive teststests/core/tests/polaris-mode/belongs-to-field-read-test.ts- Updated/removed tests around undefined vs null handlingtests/core/tests/schema-dsl/resource-decorator-test.ts- Added type assertions, removed duplicate test3. Notable Additions, Deletions, or Refactorings
Additions:
getRemoteRelationshipcovering null, undefined, and dirty states$keyderived field added to all schemasDeletions:
Key Refactorings:
legacyGetResourceRelationshipData: Simplified conditional logic using??operator for cleaner null/undefined handlinghasReceivedDataflag (only remote updates do)4. Potential Concerns & Important Details
$keyfield to all schemas - may affect type inference or schema validation elsewhere✅ Improvements:
Critical Logic Change:
The fix in
legacyGetResourceRelationshipDataensures that whenhasReceivedDatais true, it returns the actual value (null or undefined) rather than conditionally checking both state and received data separately, preventing the "undefined when should be null" bug.