[2025-10] Document updated cartDeliveryAddressesUpdate empty array behavior#3283
[2025-10] Document updated cartDeliveryAddressesUpdate empty array behavior#3283juanpprieto wants to merge 11 commits intomainfrom
cartDeliveryAddressesUpdate empty array behavior#3283Conversation
|
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
cartDeliveryAddressesUpdate empty array behavior
There was a problem hiding this comment.
Pull Request Overview
This PR documents the API behavior change in Shopify Storefront API 2025-10 where cartDeliveryAddressesUpdate now explicitly clears all delivery addresses when passed an empty array. The changes include updated JSDoc comments with examples and comprehensive test coverage to validate the documented behavior.
Key changes:
- Enhanced JSDoc with empty array clearing behavior and dual examples (clear vs update)
- Added 12 new tests covering empty arrays, multiple addresses, edge cases, and documentation validation
- Created changeset with migration guide for users upgrading to API 2025-10+
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/hydrogen/src/cart/queries/cartDeliveryAddressesUpdateDefault.tsx | Updated JSDoc to document empty array behavior and added clear/update examples |
| packages/hydrogen/src/cart/queries/cartDeliveryAddressesUpdateDefault.test.ts | Added 12 tests covering empty arrays, addresses updates, mutation structure, documentation, and edge cases |
| .changeset/delivery-address-empty-array-docs.md | Created migration guide documenting API 2025-10 breaking behavior change |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
This pull request has been marked as stale due to inactivity for 60 days. If no further activity occurs, it will be closed in 7 days. |
0a88324 to
e73a039
Compare
e73a039 to
4ac90db
Compare
2652707 to
2762305
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Reverts #3373. After merging this ^ I cancelled the workflow run before it released. There is some sort of (seemingly new) bug in our changesets logic - this PR should have been for Hydrogen/Hydrogen React versions 2025.7.3, like the title of the PR (which gets auto-generated based on the changesets). Instead, inside the body of the PR it was going to release Hydrogen/Hydrogen React 2025.10.0. [Info on Hydrogen's versioning](https://github.com/Shopify/hydrogen/blob/main/CLAUDE.md#version-strategy). I suspect this bug was probably introduced as part of [these changes](#3111) (which also had several follow up fix PRs) to try to automate as much of this as possible. Since this was added we have only had "patch" changesets in Hydrogen/Hydrogen React, but this bug surfaced the first time we did a "minor" changeset. As a follow up I will investigate this to fix the bug and get the 2025.7.3 release out.
Updated both APIs from version 2025-07 to 2025-10. Changes: - Updated version constants in all packages - Regenerated GraphQL types and schemas - Updated documentation and examples - Updated test fixtures - Created 11 tracking issues for API changes Related: #3281
- Updated LIB_VERSION in version.ts - Updated React Router preset name and version - Updated preset tests - Added Step 3c to API update guide for future updates Note: upgrade.test.ts kept at 2025.7.0 until changelog.json update
Tests verify documentation requirements: - JSDoc must document empty array clears addresses (2025-10+) - Example must show clearing addresses with empty array - Multiple address updates work correctly - Mutation structure includes error/warning handling Test Results: 2 failed, 7 passed FAILING TESTS: 1. "should document empty array behavior in JSDoc" Expected: JSDoc contains 'empty array', 'clear', '2025-10' Actual: Current JSDoc missing these keywords 2. "should include example of clearing addresses with empty array" Expected: Example showing updateAddresses([]) for clearing Actual: Example only shows updating with addresses These failures are intentional and document the required changes. Related: #3273
Updated JSDoc to document breaking behavior change: - Empty array now clears all delivery addresses (API 2025-10+) - Added separate example showing clearing operation - Clarified update vs clear semantics Changes: - Added note about empty array to clear addresses - Created two @example blocks: 1. Clear all addresses: updateAddresses([]) 2. Update specific addresses: updateAddresses([{...}]) - Referenced API version 2025-10 for new behavior Test Results: All 9 tests passing ✅ - Documentation completeness tests now pass - Empty array behavior documented - Example includes clearing with empty array Related: #3273
Added comprehensive edge case coverage: - Minimal required fields only - copyFromCustomerAddressId vs deliveryAddress - Optional parameters (country/language) - Single address update - Full address with all optional fields All tests verify function handles various input shapes correctly without enforcing validation (API responsibility). Test Results: All 14 tests passing ✅ - 2 empty array behavior tests - 2 with addresses tests - 1 cartFragment override test - 2 mutation structure tests - 2 documentation completeness tests - 5 edge case tests Related: #3273
Comprehensive changeset explaining API 2025-10 breaking change: - Before/After behavior comparison - Usage examples for clearing addresses - Migration guide for existing code - Alternative approaches using Replace mutation - Impact assessment Includes code snippets showing: - How to clear addresses with empty array - How to update specific addresses - Migration from workaround to new pattern - Reference to cartDeliveryAddressesReplace alternative Related: #3273
Fixed type errors by: - Added CountryCode import from storefront-api-types - Cast countryCode strings as CountryCode type (5 locations) - Added required 'id' field to minimalAddress test case TypeScript errors fixed: - TS2322: countryCode type incompatibility (4 errors) - TS2741: missing required 'id' property (1 error) Validation: - Typecheck: ✅ Passing - Lint: ✅ Passing - Tests: ✅ All 14 tests passing Related: #3273
Fixed review comments from copilot-pull-request-reviewer: 1. JSDoc example title formatting (comment 2453163806) - Removed API version from title for consistency - Moved API version note to description line - Now matches format of second example 2. Clarified removeDeliveryAddresses example (comment 2453163829) - Confirmed removeDeliveryAddresses exists in cartHandler API - Added cart.get() call showing complete workaround pattern - Added null safety checks (delivery?.addresses?.map) - Added length check before calling remove Changeset now shows realistic BEFORE code with: - Fetching current cart state - Extracting address IDs safely - Conditional removal based on addresses existing Validation: - Tests: ✅ All 14 passing - Typecheck: ✅ Passing - Lint: ✅ Passing Related: #3273
4ac90db to
9bc2783
Compare
2652707 to
37ee345
Compare
37ee345 to
bce6ffc
Compare
bce6ffc to
cd65345
Compare
cd65345 to
bce6ffc
Compare
bce6ffc to
cd65345
Compare
cd65345 to
bce6ffc
Compare
bce6ffc to
cd65345
Compare
cd65345 to
bce6ffc
Compare
bce6ffc to
cd65345
Compare

WHY are these changes introduced?
Fixes #3273
Shopify Storefront API 2025-10 changed
cartDeliveryAddressesUpdatemutation to explicitly clear all delivery addresses when passed an empty array. This behavior wasundefinedin previous API versions.Investigation Summary
Root Cause: API contract evolution + documentation gap (not a code defect)
Key Findings:
Conclusion: Documentation and test updates only. No code changes required.
WHAT is this pull request doing?
Changes Made (TDD Approach)
1. Added Failing Tests (Commit
40b8ff688)2. Updated Documentation (Commit
71b887210)3. Added Edge Case Tests (Commit
804c6fa6e)4. Created Changeset (Commit
2864a669d)Test Coverage Added
14 tests total (from 2 tests):
Documentation Updates
JSDoc Changes:
HOW to test your changes?
Run Tests
Expected: All 14 tests pass
Verify Documentation
Checklist