@doswiftly/storefront-operations 5.4.1 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/package.json +1 -1
- package/schema.graphql +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9a715e2: `menu(handle:)` query now resolves `MenuItem.url` and `MenuItem.resource` server-side via a batched DataLoader (~1 SQL query per resource type, no N+1).
|
|
8
|
+
|
|
9
|
+
**What changed**
|
|
10
|
+
- `MenuItem.url` for `CATEGORY` / `COLLECTION` / `PAGE` / `PRODUCT` types is now computed from the linked resource's slug/handle and follows the convention `/categories/{slug}`, `/collections/{handle}`, `/pages/{handle}`, `/products/{slug}`. Previously this field returned `null` whenever the menu item only stored a `resourceId` (the common admin-created case), making the menu unusable for navigation rendering.
|
|
11
|
+
- `MenuItem.resource` is now populated with the actual `Category` / `Collection` / `ShopPage` / `Product` object. Previously it was always `null`. Resolution is batched per resource type — fetching a 50-item menu with mixed types triggers at most 4 service calls.
|
|
12
|
+
- `Menu.itemsCount` now returns the count of top-level items (equal to `items.length`), matching the Shopify Storefront API. Previously it returned a recursive count of all items across all nesting levels, which produced confusing mismatches with `items.length`.
|
|
13
|
+
- Static types (`HTTP` / `FRONTPAGE` / `SEARCH` / `CATALOG` / `BLOG`) and orphaned resource references are unchanged in shape but now have clearer field descriptions.
|
|
14
|
+
|
|
15
|
+
**Migration**
|
|
16
|
+
|
|
17
|
+
If you relied on `Menu.itemsCount` as a recursive total, switch to client-side counting:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
function countAllItems(items: MenuItem[]): number {
|
|
21
|
+
return items.reduce((acc, item) => acc + 1 + countAllItems(item.items), 0);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If you previously worked around the missing `url` / `resource` by fetching each linked resource individually after reading the menu, you can now drop that code path.
|
|
26
|
+
|
|
3
27
|
## 5.4.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/package.json
CHANGED
package/schema.graphql
CHANGED
|
@@ -2662,7 +2662,7 @@ type Menu {
|
|
|
2662
2662
|
"""Top-level menu items"""
|
|
2663
2663
|
items: [MenuItem!]!
|
|
2664
2664
|
|
|
2665
|
-
"""
|
|
2665
|
+
"""The count of top-level items on the menu (equal to items.length)"""
|
|
2666
2666
|
itemsCount: Int!
|
|
2667
2667
|
|
|
2668
2668
|
"""Menu title"""
|
|
@@ -2680,7 +2680,9 @@ type MenuItem {
|
|
|
2680
2680
|
"""Child menu items (max 3 levels)"""
|
|
2681
2681
|
items: [MenuItem!]!
|
|
2682
2682
|
|
|
2683
|
-
"""
|
|
2683
|
+
"""
|
|
2684
|
+
Linked resource object resolved server-side via DataLoader (batched per resource type — no N+1). Null when type is HTTP/FRONTPAGE/SEARCH/CATALOG/BLOG, or when resourceId points to a deleted resource.
|
|
2685
|
+
"""
|
|
2684
2686
|
resource: MenuItemResource
|
|
2685
2687
|
|
|
2686
2688
|
"""Linked resource ID"""
|
|
@@ -2692,7 +2694,9 @@ type MenuItem {
|
|
|
2692
2694
|
"""Link type"""
|
|
2693
2695
|
type: MenuItemType!
|
|
2694
2696
|
|
|
2695
|
-
"""
|
|
2697
|
+
"""
|
|
2698
|
+
Resolved URL path computed server-side (e.g., /categories/funko, /products/toy-1, /pages/about, /collections/sale). Static types resolve to /, /search, /products, /blog. HTTP type returns the manually stored URL. Null only when type is a resource link (CATEGORY/COLLECTION/PAGE/PRODUCT) and the resource was deleted.
|
|
2699
|
+
"""
|
|
2696
2700
|
url: String
|
|
2697
2701
|
}
|
|
2698
2702
|
|