@magento/peregrine 12.0.0 → 12.2.0-alpha.1
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/lib/Apollo/clearCartDataFromCache.js +11 -12
- package/lib/Apollo/clearCustomerDataFromCache.js +15 -8
- package/lib/Apollo/policies/index.js +35 -3
- package/lib/Toasts/useToasts.js +5 -0
- package/lib/context/cart.js +21 -1
- package/lib/hooks/useCustomerWishlistSkus/customerWishlist.gql.ce.js +3 -3
- package/lib/store/actions/cart/asyncActions.js +2 -3
- package/lib/store/actions/user/asyncActions.js +2 -4
- package/lib/store/reducers/catalog.js +7 -7
- package/lib/store/reducers/user.js +1 -3
- package/lib/talons/Adapter/useAdapter.js +80 -11
- package/lib/talons/AddToCartDialog/addToCartDialog.gql.js +2 -2
- package/lib/talons/AddressBookPage/addressBookPage.gql.js +3 -9
- package/lib/talons/Breadcrumbs/breadcrumbs.gql.js +16 -12
- package/lib/talons/Breadcrumbs/useBreadcrumbs.js +6 -4
- package/lib/talons/CartPage/GiftCards/giftCardQueries.gql.ee.js +2 -2
- package/lib/talons/CartPage/PriceAdjustments/CouponCode/couponCode.gql.js +2 -3
- package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/shippingMethods.gql.js +1 -1
- package/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js +2 -1
- package/lib/talons/CartPage/ProductListing/EditModal/__fixtures__/configurableProduct.js +1 -0
- package/lib/talons/CartPage/ProductListing/EditModal/productForm.gql.js +10 -7
- package/lib/talons/CartPage/ProductListing/EditModal/productFormFragment.gql.js +7 -3
- package/lib/talons/CartPage/ProductListing/EditModal/useProductForm.js +3 -2
- package/lib/talons/CartPage/ProductListing/product.gql.js +2 -1
- package/lib/talons/CartPage/ProductListing/productListing.gql.ce.js +2 -1
- package/lib/talons/CartPage/ProductListing/productListing.gql.ee.js +2 -1
- package/lib/talons/CartPage/ProductListing/productListingFragments.gql.js +15 -5
- package/lib/talons/CartPage/ProductListing/useProduct.js +12 -5
- package/lib/talons/CartPage/ProductListing/useProductListing.js +4 -2
- package/lib/talons/CartPage/useCartPage.js +4 -3
- package/lib/talons/CategoryList/categoryList.gql.js +25 -17
- package/lib/talons/CategoryList/useCategoryList.js +6 -1
- package/lib/talons/CategoryList/useCategoryTile.js +2 -0
- package/lib/talons/CategoryTree/categoryTree.gql.js +18 -12
- package/lib/talons/CategoryTree/useCategoryBranch.js +1 -1
- package/lib/talons/CategoryTree/useCategoryTree.js +5 -5
- package/lib/talons/CheckoutPage/AddressBook/addressBook.gql.js +1 -1
- package/lib/talons/CheckoutPage/BillingAddress/billingAddress.gql.js +1 -1
- package/lib/talons/CheckoutPage/ItemsReview/__fixtures__/cartItems.js +12 -12
- package/lib/talons/CheckoutPage/ItemsReview/itemsReview.gql.js +2 -1
- package/lib/talons/CheckoutPage/ItemsReview/itemsReviewFragments.gql.js +11 -5
- package/lib/talons/CheckoutPage/OrderConfirmationPage/createAccount.gql.js +12 -6
- package/lib/talons/CheckoutPage/PaymentInformation/creditCard.gql.js +2 -2
- package/lib/talons/CheckoutPage/PaymentInformation/paymentInformation.gql.js +2 -2
- package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/customerForm.gql.js +3 -5
- package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js +12 -4
- package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/useGuestForm.js +45 -5
- package/lib/talons/CheckoutPage/ShippingInformation/shippingInformation.gql.js +2 -2
- package/lib/talons/CheckoutPage/ShippingMethod/shippingMethod.gql.js +1 -1
- package/lib/talons/CheckoutPage/checkoutPage.gql.js +2 -2
- package/lib/talons/CheckoutPage/checkoutPageFragments.gql.js +4 -2
- package/lib/talons/CheckoutPage/useCheckoutPage.js +5 -2
- package/lib/talons/Cms/cmsPage.gql.js +0 -4
- package/lib/talons/Cms/useCmsPage.js +6 -23
- package/lib/talons/CommunicationsPage/communicationsPage.gql.js +2 -2
- package/lib/talons/ContactPage/contactUs.gql.js +48 -0
- package/lib/talons/ContactPage/index.js +2 -0
- package/lib/talons/ContactPage/useContactLink.js +27 -0
- package/lib/talons/ContactPage/useContactPage.js +85 -0
- package/lib/talons/CreateAccount/createAccount.gql.js +15 -8
- package/lib/talons/CreateAccount/useCreateAccount.js +2 -4
- package/lib/talons/Footer/footer.gql.js +2 -1
- package/lib/talons/FormError/useFormError.js +9 -7
- package/lib/talons/Gallery/__fixtures__/apolloMocks.js +2 -2
- package/lib/talons/Gallery/gallery.gql.ce.js +2 -1
- package/lib/talons/Gallery/gallery.gql.ee.js +2 -1
- package/lib/talons/Gallery/useAddToCartButton.js +28 -13
- package/lib/talons/Header/storeSwitcher.gql.js +21 -9
- package/lib/talons/Header/useCartTrigger.js +3 -3
- package/lib/talons/Header/useStoreSwitcher.js +10 -8
- package/lib/talons/MagentoRoute/magentoRoute.gql.js +4 -2
- package/lib/talons/MagentoRoute/useMagentoRoute.js +39 -33
- package/lib/talons/MegaMenu/megaMenu.gql.js +10 -5
- package/lib/talons/MegaMenu/useMegaMenu.js +3 -5
- package/lib/talons/MegaMenu/useMegaMenuItem.js +5 -0
- package/lib/talons/MiniCart/ProductList/productListFragments.gql.js +11 -5
- package/lib/talons/MiniCart/miniCart.gql.js +2 -1
- package/lib/talons/MiniCart/useItem.js +3 -3
- package/lib/talons/MiniCart/useMiniCart.js +8 -7
- package/lib/talons/Navigation/navigation.gql.js +4 -3
- package/lib/talons/Navigation/useNavigation.js +1 -1
- package/lib/talons/Newsletter/newsletter.gql.js +24 -0
- package/lib/talons/Newsletter/useNewsletter.js +70 -0
- package/lib/talons/OrderHistoryPage/orderHistoryContext.gql.js +2 -1
- package/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js +1 -1
- package/lib/talons/OrderHistoryPage/orderRow.gql.js +7 -3
- package/lib/talons/ProductFullDetail/CustomAttributes/AttributeType/useAttributeType.js +26 -0
- package/lib/talons/ProductFullDetail/productFullDetail.gql.ce.js +4 -3
- package/lib/talons/ProductFullDetail/productFullDetail.gql.ee.js +2 -1
- package/lib/talons/ProductFullDetail/useProductFullDetail.js +35 -3
- package/lib/talons/RootComponents/Category/category.gql.js +7 -4
- package/lib/talons/RootComponents/Category/categoryContent.gql.js +26 -7
- package/lib/talons/RootComponents/Category/categoryFragments.gql.js +5 -2
- package/lib/talons/RootComponents/Category/useCategory.js +8 -6
- package/lib/talons/RootComponents/Category/useCategoryContent.js +30 -3
- package/lib/talons/RootComponents/Category/useNoProductsFound.js +0 -1
- package/lib/talons/RootComponents/Product/product.gql.js +3 -1
- package/lib/talons/RootComponents/Product/productDetailFragment.gql.js +69 -10
- package/lib/talons/SearchPage/searchPage.gql.js +18 -2
- package/lib/talons/SearchPage/useSearchPage.js +25 -0
- package/lib/talons/SignIn/signIn.gql.js +4 -3
- package/lib/talons/SignIn/useSignIn.js +2 -4
- package/lib/talons/Wishlist/WishlistDialog/wishlistDialog.gql.js +3 -2
- package/lib/talons/WishlistPage/createWishlist.gql.js +2 -1
- package/lib/talons/WishlistPage/useWishlistItem.js +2 -2
- package/lib/talons/WishlistPage/wishlist.gql.js +2 -2
- package/lib/talons/WishlistPage/wishlistConfig.gql.ce.js +2 -1
- package/lib/talons/WishlistPage/wishlistConfig.gql.ee.js +2 -1
- package/lib/talons/WishlistPage/wishlistItemFragments.gql.js +5 -2
- package/lib/talons/WishlistPage/wishlistPage.gql.js +1 -1
- package/package.json +6 -6
- package/lib/Apollo/clearStore.js +0 -26
- package/lib/Apollo/deleteCacheEntry.js +0 -87
|
@@ -3,20 +3,20 @@ import { gql } from '@apollo/client';
|
|
|
3
3
|
export const ProductDetailsFragment = gql`
|
|
4
4
|
fragment ProductDetailsFragment on ProductInterface {
|
|
5
5
|
__typename
|
|
6
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
7
|
categories {
|
|
7
|
-
|
|
8
|
+
uid
|
|
8
9
|
breadcrumbs {
|
|
9
|
-
|
|
10
|
+
category_uid
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
description {
|
|
13
14
|
html
|
|
14
15
|
}
|
|
15
16
|
id
|
|
17
|
+
uid
|
|
18
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
16
19
|
media_gallery_entries {
|
|
17
|
-
# id is deprecated and unused in our code, but lint rules require we
|
|
18
|
-
# request it if available
|
|
19
|
-
id
|
|
20
20
|
uid
|
|
21
21
|
label
|
|
22
22
|
position
|
|
@@ -39,12 +39,43 @@ export const ProductDetailsFragment = gql`
|
|
|
39
39
|
}
|
|
40
40
|
stock_status
|
|
41
41
|
url_key
|
|
42
|
+
custom_attributes {
|
|
43
|
+
selected_attribute_options {
|
|
44
|
+
attribute_option {
|
|
45
|
+
uid
|
|
46
|
+
label
|
|
47
|
+
is_default
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
entered_attribute_value {
|
|
51
|
+
value
|
|
52
|
+
}
|
|
53
|
+
attribute_metadata {
|
|
54
|
+
uid
|
|
55
|
+
code
|
|
56
|
+
label
|
|
57
|
+
attribute_labels {
|
|
58
|
+
store_code
|
|
59
|
+
label
|
|
60
|
+
}
|
|
61
|
+
data_type
|
|
62
|
+
is_system
|
|
63
|
+
is_visible_on_front
|
|
64
|
+
entity_type
|
|
65
|
+
ui_input {
|
|
66
|
+
ui_input_type
|
|
67
|
+
is_html_allowed
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
42
71
|
... on ConfigurableProduct {
|
|
72
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
43
73
|
configurable_options {
|
|
44
74
|
attribute_code
|
|
45
75
|
attribute_id
|
|
46
|
-
|
|
76
|
+
uid
|
|
47
77
|
label
|
|
78
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
48
79
|
values {
|
|
49
80
|
uid
|
|
50
81
|
default_label
|
|
@@ -65,12 +96,11 @@ export const ProductDetailsFragment = gql`
|
|
|
65
96
|
code
|
|
66
97
|
value_index
|
|
67
98
|
}
|
|
99
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
68
100
|
product {
|
|
69
|
-
|
|
101
|
+
uid
|
|
102
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
70
103
|
media_gallery_entries {
|
|
71
|
-
# id is deprecated and unused in our code, but lint rules require we
|
|
72
|
-
# request it if available
|
|
73
|
-
id
|
|
74
104
|
uid
|
|
75
105
|
disabled
|
|
76
106
|
file
|
|
@@ -87,6 +117,35 @@ export const ProductDetailsFragment = gql`
|
|
|
87
117
|
}
|
|
88
118
|
}
|
|
89
119
|
}
|
|
120
|
+
custom_attributes {
|
|
121
|
+
selected_attribute_options {
|
|
122
|
+
attribute_option {
|
|
123
|
+
uid
|
|
124
|
+
label
|
|
125
|
+
is_default
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
entered_attribute_value {
|
|
129
|
+
value
|
|
130
|
+
}
|
|
131
|
+
attribute_metadata {
|
|
132
|
+
uid
|
|
133
|
+
code
|
|
134
|
+
label
|
|
135
|
+
attribute_labels {
|
|
136
|
+
store_code
|
|
137
|
+
label
|
|
138
|
+
}
|
|
139
|
+
data_type
|
|
140
|
+
is_system
|
|
141
|
+
is_visible_on_front
|
|
142
|
+
entity_type
|
|
143
|
+
ui_input {
|
|
144
|
+
ui_input_type
|
|
145
|
+
is_html_allowed
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
90
149
|
}
|
|
91
150
|
}
|
|
92
151
|
}
|
|
@@ -2,8 +2,9 @@ import { gql } from '@apollo/client';
|
|
|
2
2
|
|
|
3
3
|
export const GET_PAGE_SIZE = gql`
|
|
4
4
|
query getPageSize {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
5
6
|
storeConfig {
|
|
6
|
-
|
|
7
|
+
store_code
|
|
7
8
|
grid_per_page
|
|
8
9
|
}
|
|
9
10
|
}
|
|
@@ -42,6 +43,7 @@ export const PRODUCT_SEARCH = gql`
|
|
|
42
43
|
) {
|
|
43
44
|
items {
|
|
44
45
|
id
|
|
46
|
+
uid
|
|
45
47
|
name
|
|
46
48
|
price_range {
|
|
47
49
|
maximum_price {
|
|
@@ -56,7 +58,7 @@ export const PRODUCT_SEARCH = gql`
|
|
|
56
58
|
url
|
|
57
59
|
}
|
|
58
60
|
stock_status
|
|
59
|
-
|
|
61
|
+
__typename
|
|
60
62
|
url_key
|
|
61
63
|
}
|
|
62
64
|
page_info {
|
|
@@ -80,9 +82,23 @@ export const GET_FILTER_INPUTS = gql`
|
|
|
80
82
|
}
|
|
81
83
|
`;
|
|
82
84
|
|
|
85
|
+
export const GET_SEARCH_AVAILABLE_SORT_METHODS = gql`
|
|
86
|
+
query getSearchAvailableSortMethods($search: String!) {
|
|
87
|
+
products(search: $search) {
|
|
88
|
+
sort_fields {
|
|
89
|
+
options {
|
|
90
|
+
label
|
|
91
|
+
value
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
|
|
83
98
|
export default {
|
|
84
99
|
getFilterInputsQuery: GET_FILTER_INPUTS,
|
|
85
100
|
getPageSize: GET_PAGE_SIZE,
|
|
86
101
|
getProductFiltersBySearchQuery: GET_PRODUCT_FILTERS_BY_SEARCH,
|
|
102
|
+
getSearchAvailableSortMethods: GET_SEARCH_AVAILABLE_SORT_METHODS,
|
|
87
103
|
productSearchQuery: PRODUCT_SEARCH
|
|
88
104
|
};
|
|
@@ -25,6 +25,7 @@ export const useSearchPage = (props = {}) => {
|
|
|
25
25
|
getFilterInputsQuery,
|
|
26
26
|
getPageSize,
|
|
27
27
|
getProductFiltersBySearchQuery,
|
|
28
|
+
getSearchAvailableSortMethods,
|
|
28
29
|
productSearchQuery
|
|
29
30
|
} = operations;
|
|
30
31
|
|
|
@@ -32,6 +33,15 @@ export const useSearchPage = (props = {}) => {
|
|
|
32
33
|
fetchPolicy: 'cache-and-network',
|
|
33
34
|
nextFetchPolicy: 'cache-first'
|
|
34
35
|
});
|
|
36
|
+
|
|
37
|
+
const [getSortMethods, { data: sortData }] = useLazyQuery(
|
|
38
|
+
getSearchAvailableSortMethods,
|
|
39
|
+
{
|
|
40
|
+
fetchPolicy: 'cache-and-network',
|
|
41
|
+
nextFetchPolicy: 'cache-first'
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
35
45
|
const pageSize = pageSizeData && pageSizeData.storeConfig.grid_per_page;
|
|
36
46
|
|
|
37
47
|
const sortProps = useSort();
|
|
@@ -193,6 +203,16 @@ export const useSearchPage = (props = {}) => {
|
|
|
193
203
|
}
|
|
194
204
|
}, [currentSort, search, setCurrentPage]);
|
|
195
205
|
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
if (inputText) {
|
|
208
|
+
getSortMethods({
|
|
209
|
+
variables: {
|
|
210
|
+
search: inputText
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}, [inputText, getSortMethods]);
|
|
215
|
+
|
|
196
216
|
// Fetch category filters for when a user is searching in a category.
|
|
197
217
|
const [getFilters, { data: filterData }] = useLazyQuery(
|
|
198
218
|
getProductFiltersBySearchQuery,
|
|
@@ -224,7 +244,12 @@ export const useSearchPage = (props = {}) => {
|
|
|
224
244
|
|
|
225
245
|
useScrollTopOnChange(currentPage);
|
|
226
246
|
|
|
247
|
+
const availableSortMethods = sortData
|
|
248
|
+
? sortData.products.sort_fields.options
|
|
249
|
+
: null;
|
|
250
|
+
|
|
227
251
|
return {
|
|
252
|
+
availableSortMethods,
|
|
228
253
|
data,
|
|
229
254
|
error,
|
|
230
255
|
filters,
|
|
@@ -3,8 +3,8 @@ import { CheckoutPageFragment } from '../CheckoutPage/checkoutPageFragments.gql'
|
|
|
3
3
|
|
|
4
4
|
export const GET_CUSTOMER = gql`
|
|
5
5
|
query GetCustomerAfterSignIn {
|
|
6
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
7
|
customer {
|
|
7
|
-
id
|
|
8
8
|
email
|
|
9
9
|
firstname
|
|
10
10
|
lastname
|
|
@@ -35,10 +35,11 @@ export const MERGE_CARTS = gql`
|
|
|
35
35
|
mergeCarts(
|
|
36
36
|
source_cart_id: $sourceCartId
|
|
37
37
|
destination_cart_id: $destinationCartId
|
|
38
|
-
)
|
|
38
|
+
) {
|
|
39
39
|
id
|
|
40
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
40
41
|
items {
|
|
41
|
-
|
|
42
|
+
uid
|
|
42
43
|
}
|
|
43
44
|
...CheckoutPageFragment
|
|
44
45
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useCallback, useRef, useState, useMemo } from 'react';
|
|
2
2
|
import { useApolloClient, useMutation } from '@apollo/client';
|
|
3
3
|
|
|
4
|
-
import { clearCartDataFromCache } from '../../Apollo/clearCartDataFromCache';
|
|
5
|
-
import { clearCustomerDataFromCache } from '../../Apollo/clearCustomerDataFromCache';
|
|
6
4
|
import mergeOperations from '../../util/shallowMerge';
|
|
7
5
|
import { useCartContext } from '../../context/cart';
|
|
8
6
|
import { useUserContext } from '../../context/user';
|
|
@@ -67,8 +65,8 @@ export const useSignIn = props => {
|
|
|
67
65
|
await setToken(token);
|
|
68
66
|
|
|
69
67
|
// Clear all cart/customer data from cache and redux.
|
|
70
|
-
await
|
|
71
|
-
await
|
|
68
|
+
await apolloClient.clearCacheData(apolloClient, 'cart');
|
|
69
|
+
await apolloClient.clearCacheData(apolloClient, 'checkout');
|
|
72
70
|
await removeCart();
|
|
73
71
|
|
|
74
72
|
// Create and get the customer's cart id.
|
|
@@ -23,13 +23,14 @@ export const ADD_TO_WISHLIST = gql`
|
|
|
23
23
|
|
|
24
24
|
export const GET_WISHLISTS = gql`
|
|
25
25
|
query getWishlistsDialogData {
|
|
26
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
26
27
|
storeConfig {
|
|
27
|
-
|
|
28
|
+
store_code
|
|
28
29
|
enable_multiple_wishlists
|
|
29
30
|
maximum_number_of_wishlists
|
|
30
31
|
}
|
|
32
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
31
33
|
customer {
|
|
32
|
-
id
|
|
33
34
|
wishlists {
|
|
34
35
|
id
|
|
35
36
|
name
|
|
@@ -12,8 +12,9 @@ export const CREATE_WISHLIST = gql`
|
|
|
12
12
|
|
|
13
13
|
export const GET_MULTIPLE_WISHLISTS_ENABLED = gql`
|
|
14
14
|
query getMultipleWishlistsEnabled {
|
|
15
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
15
16
|
storeConfig {
|
|
16
|
-
|
|
17
|
+
store_code
|
|
17
18
|
enable_multiple_wishlists
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -81,8 +81,8 @@ export const useWishlistItem = props => {
|
|
|
81
81
|
const selectedOptionsArray = selectedConfigurableOptions.map(
|
|
82
82
|
selectedOption => {
|
|
83
83
|
const {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
configurable_product_option_uid: attributeId,
|
|
85
|
+
configurable_product_option_value_uid: selectedValueId
|
|
86
86
|
} = selectedOption;
|
|
87
87
|
const configurableOption = configurableOptions.find(
|
|
88
88
|
option => option.attribute_id_v2 === attributeId
|
|
@@ -5,8 +5,8 @@ import { WishlistItemFragment } from './wishlistItemFragments.gql';
|
|
|
5
5
|
|
|
6
6
|
export const GET_CUSTOMER_WISHLIST = gql`
|
|
7
7
|
query GetCustomerWishlist {
|
|
8
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
8
9
|
customer {
|
|
9
|
-
id
|
|
10
10
|
wishlists {
|
|
11
11
|
id
|
|
12
12
|
...WishlistPageFragment
|
|
@@ -18,8 +18,8 @@ export const GET_CUSTOMER_WISHLIST = gql`
|
|
|
18
18
|
|
|
19
19
|
export const GET_CUSTOMER_WISHLIST_ITEMS = gql`
|
|
20
20
|
query getCustomerWishlist($id: ID!, $currentPage: Int) {
|
|
21
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
21
22
|
customer {
|
|
22
|
-
id
|
|
23
23
|
wishlist_v2(id: $id) {
|
|
24
24
|
id
|
|
25
25
|
items_v2(currentPage: $currentPage) {
|
|
@@ -2,8 +2,9 @@ import { gql } from '@apollo/client';
|
|
|
2
2
|
|
|
3
3
|
export const GET_WISHLIST_CONFIG = gql`
|
|
4
4
|
query GetWishlistConfigForWishlistPageCE {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
5
6
|
storeConfig {
|
|
6
|
-
|
|
7
|
+
store_code
|
|
7
8
|
magento_wishlist_general_is_enabled
|
|
8
9
|
}
|
|
9
10
|
}
|
|
@@ -2,8 +2,9 @@ import { gql } from '@apollo/client';
|
|
|
2
2
|
|
|
3
3
|
export const GET_WISHLIST_CONFIG = gql`
|
|
4
4
|
query GetWishlistConfigForWishlistPageEE {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
5
6
|
storeConfig {
|
|
6
|
-
|
|
7
|
+
store_code
|
|
7
8
|
magento_wishlist_general_is_enabled
|
|
8
9
|
enable_multiple_wishlists
|
|
9
10
|
}
|
|
@@ -3,8 +3,9 @@ import { gql } from '@apollo/client';
|
|
|
3
3
|
export const WishlistItemFragment = gql`
|
|
4
4
|
fragment WishlistItemFragment on WishlistItemInterface {
|
|
5
5
|
id
|
|
6
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
7
|
product {
|
|
7
|
-
|
|
8
|
+
uid
|
|
8
9
|
image {
|
|
9
10
|
label
|
|
10
11
|
url
|
|
@@ -20,9 +21,11 @@ export const WishlistItemFragment = gql`
|
|
|
20
21
|
}
|
|
21
22
|
sku
|
|
22
23
|
stock_status
|
|
24
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
23
25
|
... on ConfigurableProduct {
|
|
26
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
24
27
|
configurable_options {
|
|
25
|
-
|
|
28
|
+
uid
|
|
26
29
|
attribute_code
|
|
27
30
|
attribute_id
|
|
28
31
|
attribute_id_v2
|
|
@@ -4,8 +4,8 @@ import { WishlistPageFragment } from './wishlistFragment.gql';
|
|
|
4
4
|
|
|
5
5
|
export const GET_CUSTOMER_WISHLIST = gql`
|
|
6
6
|
query GetCustomerWishlist {
|
|
7
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
7
8
|
customer {
|
|
8
|
-
id
|
|
9
9
|
wishlists {
|
|
10
10
|
id
|
|
11
11
|
...WishlistPageFragment
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magento/peregrine",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.2.0-alpha.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/magento/pwa-studio/issues"
|
|
17
17
|
},
|
|
18
|
-
"homepage": "https://github.com/magento/pwa-studio/tree/
|
|
18
|
+
"homepage": "https://github.com/magento/pwa-studio/tree/main/packages/peregrine#readme",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"fast-glob": "~3.2.4"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@apollo/client": "~3.
|
|
23
|
+
"@apollo/client": "~3.4.0",
|
|
24
24
|
"@magento/eslint-config": "~1.5.0",
|
|
25
25
|
"@testing-library/react-hooks": "~5.0.3",
|
|
26
26
|
"intl": "~1.2.5",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"wait-for-expect": "~1.2.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@apollo/client": "~3.
|
|
40
|
-
"@babel/runtime": "~7.
|
|
39
|
+
"@apollo/client": "~3.4.0",
|
|
40
|
+
"@babel/runtime": "~7.15.3",
|
|
41
41
|
"informed": "~3.29.0",
|
|
42
42
|
"react": "~17.0.1",
|
|
43
43
|
"react-dom": "~17.0.1",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"redux-actions": "~2.6.5"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
51
|
+
"node": ">=14.x",
|
|
52
52
|
"yarn": ">=1.12.0"
|
|
53
53
|
},
|
|
54
54
|
"pwa-studio": {
|
package/lib/Apollo/clearStore.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wipes the apollo cache in memory and persistence.
|
|
3
|
-
*
|
|
4
|
-
* According to Apollo's docs you should only have to call client.clearStore
|
|
5
|
-
* but if you use a persistence layer such as apollo-cache-persist you MUST
|
|
6
|
-
* pause and purge the persistor's buffer _before_ calling clear store otherwise
|
|
7
|
-
* the data is immediately replayed into the client store from the persistor.
|
|
8
|
-
*
|
|
9
|
-
* See: https://github.com/apollographql/apollo-cache-persist/issues/34#issuecomment-371177206
|
|
10
|
-
*
|
|
11
|
-
* @param {ApolloClient} client apollo client instance
|
|
12
|
-
* @param {PersistorInstance} persistor persistor instance
|
|
13
|
-
*/
|
|
14
|
-
export const clearStore = async (client, persistor) => {
|
|
15
|
-
// Pause automatic persistence.
|
|
16
|
-
persistor.pause();
|
|
17
|
-
|
|
18
|
-
// Delete everything in the storage provider.
|
|
19
|
-
await persistor.purge();
|
|
20
|
-
|
|
21
|
-
// Wipe the apollo store. Do not replay queries.
|
|
22
|
-
await client.clearStore();
|
|
23
|
-
|
|
24
|
-
// Resume automatic persistence.
|
|
25
|
-
persistor.resume();
|
|
26
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { CACHE_PERSIST_PREFIX } from '@magento/peregrine/lib/Apollo/constants';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Deletes specific entry/entries from the apollo cache and then tries to
|
|
5
|
-
* persist the deletions.
|
|
6
|
-
*
|
|
7
|
-
* @param {ApolloClient} client apollo client instance
|
|
8
|
-
* @param {Function} predicate a matching function
|
|
9
|
-
*/
|
|
10
|
-
export const deleteCacheEntry = async (client, predicate) => {
|
|
11
|
-
await deleteActiveCacheEntry(client, predicate);
|
|
12
|
-
await deleteInactiveCachesEntry(client, predicate);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const deleteActiveCacheEntry = async (client, predicate) => {
|
|
16
|
-
// If there is no client or cache then just back out since it doesn't matter :D
|
|
17
|
-
if (
|
|
18
|
-
!client ||
|
|
19
|
-
!client.cache ||
|
|
20
|
-
!client.cache.data ||
|
|
21
|
-
!client.cache.data.data
|
|
22
|
-
) {
|
|
23
|
-
if (process.env.NODE_ENV === 'development') {
|
|
24
|
-
console.warn(
|
|
25
|
-
'Apollo Cache entry deletion attempted without client or cache.'
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Remove from the active cache.
|
|
32
|
-
Object.keys(client.cache.data.data).forEach(key => {
|
|
33
|
-
if (predicate(key)) {
|
|
34
|
-
client.cache.data.delete(key);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Remove from ROOT_QUERY cache.
|
|
39
|
-
if (client.cache.data.data.ROOT_QUERY) {
|
|
40
|
-
Object.keys(client.cache.data.data.ROOT_QUERY).forEach(key => {
|
|
41
|
-
if (predicate(key)) {
|
|
42
|
-
client.cache.data.delete('ROOT_QUERY', key);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Immediately persist the cache changes to the active cache storage.
|
|
48
|
-
if (client.persistor) {
|
|
49
|
-
await client.persistor.persist();
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const deleteInactiveCachesEntry = async (client, predicate) => {
|
|
54
|
-
if (!client || !client.persistor || !globalThis.localStorage) return;
|
|
55
|
-
|
|
56
|
-
const activeApolloCacheLocalStorageKey =
|
|
57
|
-
client.persistor.persistor.storage.key;
|
|
58
|
-
|
|
59
|
-
const isAnInactiveApolloCache = ([key]) => {
|
|
60
|
-
return (
|
|
61
|
-
key.startsWith(CACHE_PERSIST_PREFIX) &&
|
|
62
|
-
key !== activeApolloCacheLocalStorageKey
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const { localStorage } = globalThis;
|
|
67
|
-
|
|
68
|
-
Object.entries(localStorage)
|
|
69
|
-
.filter(isAnInactiveApolloCache)
|
|
70
|
-
.forEach(([inactiveCacheKey, inactiveCacheValue]) => {
|
|
71
|
-
const inactiveApolloCache = JSON.parse(inactiveCacheValue);
|
|
72
|
-
|
|
73
|
-
Object.keys(inactiveApolloCache).forEach(key => {
|
|
74
|
-
if (predicate(key)) {
|
|
75
|
-
delete inactiveApolloCache[key];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// We're done deleting keys that match the predicate,
|
|
80
|
-
// but we've only mutated the object in memory.
|
|
81
|
-
// Write the updated inactive cache back out to localStorage.
|
|
82
|
-
localStorage.setItem(
|
|
83
|
-
inactiveCacheKey,
|
|
84
|
-
JSON.stringify(inactiveApolloCache)
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
};
|