@graphcommerce/magento-wishlist 1.0.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +62 -0
  3. package/components/ProductWishlistChip/ProductWishlistChip.graphql +4 -0
  4. package/components/ProductWishlistChip/ProductWishlistChip.tsx +5 -0
  5. package/components/ProductWishlistChip/ProductWishlistChipBase.tsx +180 -0
  6. package/components/ProductWishlistChip/ProductWishlistChipDetail.tsx +12 -0
  7. package/components/ProductWishlistChip/ProductWishlistChipDetailConfigurable.tsx +23 -0
  8. package/components/WishlistFab/WishlistFab.tsx +91 -0
  9. package/components/WishlistItem/ProductAddToCart.tsx +135 -0
  10. package/components/WishlistItem/WishlistItem.graphql +3 -0
  11. package/components/WishlistItem/WishlistItem.tsx +30 -0
  12. package/components/WishlistItem/WishlistItemBase.tsx +303 -0
  13. package/components/WishlistItem/WishlistItemConfigurable.graphql +8 -0
  14. package/components/WishlistItem/WishlistItemConfigurable.tsx +11 -0
  15. package/components/WishlistItem/WishlistItemProduct.graphql +11 -0
  16. package/components/WishlistItems/WishlistItems.graphql +12 -0
  17. package/components/WishlistItems/WishlistItems.tsx +33 -0
  18. package/components/WishlistMenuFabItem/WishlistMenuFabItem.tsx +81 -0
  19. package/components/index.ts +10 -0
  20. package/hooks/index.ts +3 -0
  21. package/hooks/useMergeGuestWishlistWithCustomer.tsx +64 -0
  22. package/hooks/useWishlistEnabled.tsx +9 -0
  23. package/hooks/useWishlistItems.tsx +53 -0
  24. package/index.ts +12 -0
  25. package/package.json +39 -0
  26. package/queries/AddProductToWishlist.graphql +13 -0
  27. package/queries/GetGuestWishlistProducts.graphql +14 -0
  28. package/queries/GetIsInWishlists.graphql +7 -0
  29. package/queries/GetWishlistProducts.graphql +19 -0
  30. package/queries/GuestWishlist.graphql +11 -0
  31. package/queries/GuestWishlist.graphqls +13 -0
  32. package/queries/RemoveProductFromWishlist.graphql +7 -0
  33. package/queries/WishlistStoreConfigFragment.graphql +3 -0
  34. package/queries/WishlistSummaryFragment.graphql +13 -0
  35. package/tsconfig.json +5 -0
  36. package/typePolicies.ts +21 -0
@@ -0,0 +1,14 @@
1
+ query GetGuestWishlistProducts(
2
+ $pageSize: Int = 33
3
+ $currentPage: Int = 1
4
+ $filters: ProductAttributeFilterInput = {}
5
+ $sort: ProductAttributeSortInput = {}
6
+ ) {
7
+ products(pageSize: $pageSize, currentPage: $currentPage, filter: $filters, sort: $sort) {
8
+ items {
9
+ __typename
10
+ uid
11
+ ...ProductListItem
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,7 @@
1
+ query GetIsInWishlists {
2
+ customer {
3
+ wishlists {
4
+ ...WishlistSummaryFragment
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,19 @@
1
+ query GetWishlistProducts {
2
+ customer {
3
+ wishlists {
4
+ id
5
+ items_count
6
+ items_v2 {
7
+ items {
8
+ id
9
+ ...WishlistItem
10
+ product {
11
+ uid
12
+ sku
13
+ ...ProductListItem
14
+ }
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ query GuestWishlist {
2
+ guestWishlist @client {
3
+ __typename
4
+ items {
5
+ __typename
6
+ sku
7
+ selected_options
8
+ quantity
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,13 @@
1
+ extend type Query {
2
+ guestWishlist: GuestWishlist
3
+ }
4
+
5
+ type GuestWishlist {
6
+ items: [GuestWishlistItem!]!
7
+ }
8
+
9
+ type GuestWishlistItem {
10
+ sku: String!
11
+ selected_options: [ID]
12
+ quantity: Float!
13
+ }
@@ -0,0 +1,7 @@
1
+ mutation removeProductFromWishlist($wishlistItemId: ID!) {
2
+ removeProductsFromWishlist(wishlistId: 0, wishlistItemsIds: [$wishlistItemId]) {
3
+ wishlist {
4
+ ...WishlistSummaryFragment
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,3 @@
1
+ fragment WishlistStoreConfig on StoreConfig @inject(into: ["StoreConfigFragment"]) {
2
+ magento_wishlist_general_is_enabled
3
+ }
@@ -0,0 +1,13 @@
1
+ fragment WishlistSummaryFragment on Wishlist {
2
+ id
3
+ items_count
4
+ items_v2 {
5
+ items {
6
+ id
7
+ product {
8
+ uid
9
+ sku
10
+ }
11
+ }
12
+ }
13
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "exclude": ["**/node_modules", "**/.*/"],
3
+ "include": ["**/*.ts", "**/*.tsx"],
4
+ "extends": "@graphcommerce/typescript-config-pwa/nextjs.json"
5
+ }
@@ -0,0 +1,21 @@
1
+ import { TypedTypePolicies } from '@graphcommerce/graphql'
2
+
3
+ export const wishlistTypePolicies: TypedTypePolicies = {
4
+ GuestWishlist: {
5
+ keyFields: [],
6
+ fields: {
7
+ items: {
8
+ merge: (existing: Array<unknown> | undefined, incoming: Array<unknown>, options) => {
9
+ const data = existing === undefined ? [] : existing
10
+ return [...data, ...incoming]
11
+ },
12
+ },
13
+ },
14
+ },
15
+
16
+ Query: {
17
+ fields: {
18
+ guestWishlist: (_, { toReference }) => toReference({ __typename: 'GuestWishlist' }),
19
+ },
20
+ },
21
+ }