fix: use collectCreateData for nested hasMany entities in mutations#18
Merged
fix: use collectCreateData for nested hasMany entities in mutations#18
Conversation
Reviews added via store.addToHasMany to a Round nested inside an Approval create are not included in the mutation because collectHasManyOperations uses processNestedData instead of collectCreateData for nested entities.
collectHasManyOperations was using processNestedData for created entities, which only processed raw snapshot data and ignored store-tracked hasMany relations. This caused deeply nested hasMany items (e.g. Round → Reviews) to be missing from mutations when the parent was itself nested in another create.
…ter persist - MutationCollector now materializes embedded hasMany/hasOne data into proper store entities during collectCreateData, enabling tracking and post-persist ID mapping - Added connectExistingToHasMany to store for connecting existing entities without marking them as created - Extended TransactionMutationResult with nestedResults for adapters to return server-assigned IDs for inline-created entities - BatchPersister now commits nested entities after successful persist and processes nestedResults for ID mapping
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.
Summary
collectHasManyOperationsmanually read snapshot data and calledprocessNestedData, which only handled embedded data — relations added viaaddToHasMany/getOrCreateRelationwere silently droppedcollectCreateData, which already handles both embedded data and store-managed relations recursivelyTest plan
collectCreateDataincludes hasMany store statebun test)