feat: atomic relationship updates in updateBean #81
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.
Motivation
Depends on: #72
PR #72 added atomic body modifications via the
bodyModfield inupdateBean. This PR extends the same pattern to relationship fields (parent, blocking, blockedBy).Currently, updating relationships requires separate mutations with manual ETag extraction:
This PR consolidates relationship management into `updateBean` for truly atomic operations.
Changes
GraphQL API Improvements
Added relationship fields to `UpdateBeanInput`:
New capabilities:
Implementation Details
Extracted validation helpers to `resolver.go`:
Updated `updateBean` resolver:
Updated CLI (`cmd/update.go`):
Backward Compatibility
Standalone relationship mutations remain available:
No breaking changes. The new fields in `updateBean` are purely additive.
Examples
CLI - Combined operations:
GraphQL - Atomic update:
Before (multiple mutations with ETag chaining):
After (single atomic mutation):
Execution Order
Validations
All existing validations preserved:
Parent validation:
Blocking/Blocked-by validation:
Testing
Unit tests added:
Manual testing:
All tests passing ✅ (42 graph tests total)
Benefits
Questions for Consideration
Should we deprecate and remove standalone relationship mutations?
Following the same reasoning as in #72 (where we removed `replaceInBody` and `appendToBody`), we could deprecate the standalone relationship mutations to:
Affected mutations:
Migration would be straightforward:
Alternatively, we could keep both approaches available if there's value in having specialized mutations for specific use cases.
What's your preference?