@graphcommerce/magento-product 10.0.0-canary.68 → 10.0.0-canary.72
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 +12 -0
- package/components/AddProductsToCart/AddProductsToCartForm.tsx +4 -2
- package/components/AddProductsToCart/AddProductsToCartSnackbarMessage.tsx +2 -2
- package/components/ProductListItems/getFilterTypes.ts +4 -4
- package/components/ProductListItems/productListApplyCategoryDefaults.ts +5 -4
- package/components/ProductStaticPaths/getProductStaticPaths.ts +14 -8
- package/components/ProductStaticPaths/getSitemapPaths.ts +4 -4
- package/hooks/useProductList.ts +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.0.0-canary.72
|
|
4
|
+
|
|
5
|
+
## 10.0.0-canary.71
|
|
6
|
+
|
|
7
|
+
## 10.0.0-canary.70
|
|
8
|
+
|
|
9
|
+
### Major Changes
|
|
10
|
+
|
|
11
|
+
- [#2565](https://github.com/graphcommerce-org/graphcommerce/pull/2565) [`c96dfcd`](https://github.com/graphcommerce-org/graphcommerce/commit/c96dfcdca981baca387c270ad9e2b9515cdd00cc) - Updated to Apollo Client 4 ([@paales](https://github.com/paales))
|
|
12
|
+
|
|
13
|
+
## 10.0.0-canary.69
|
|
14
|
+
|
|
3
15
|
## 10.0.0-canary.68
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UseFormGraphQlOptions } from '@graphcommerce/ecommerce-ui'
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApolloClient } from '@graphcommerce/graphql'
|
|
3
3
|
import { useApolloClient } from '@graphcommerce/graphql'
|
|
4
4
|
import type { CrosssellsQuery } from '@graphcommerce/magento-cart'
|
|
5
5
|
import { CrosssellsDocument, useFormGqlMutationCart } from '@graphcommerce/magento-cart'
|
|
@@ -44,7 +44,9 @@ export function AddProductsToCartForm(props: AddProductsToCartFormProps) {
|
|
|
44
44
|
const { children, redirect, onComplete, sx, snackbarProps, ...formProps } = props
|
|
45
45
|
const router = useRouter()
|
|
46
46
|
const client = useApolloClient()
|
|
47
|
-
const crosssellsQuery = useRef<Promise<
|
|
47
|
+
const crosssellsQuery = useRef<Promise<ApolloClient.QueryResult<CrosssellsQuery>> | undefined>(
|
|
48
|
+
undefined,
|
|
49
|
+
)
|
|
48
50
|
|
|
49
51
|
const form = useFormGqlMutationCart<AddProductsToCartMutation, AddProductsToCartFields>(
|
|
50
52
|
AddProductsToCartDocument,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ApolloError } from '@graphcommerce/graphql'
|
|
2
1
|
import type { CartUserInputError } from '@graphcommerce/graphql-mesh'
|
|
3
2
|
import {
|
|
4
3
|
ApolloCartErrorSnackbar,
|
|
@@ -13,12 +12,13 @@ import {
|
|
|
13
12
|
ListFormat,
|
|
14
13
|
MessageSnackbar,
|
|
15
14
|
} from '@graphcommerce/next-ui'
|
|
15
|
+
import type { ErrorLike } from '@apollo/client'
|
|
16
16
|
import { Plural, Trans } from '@lingui/react/macro'
|
|
17
17
|
|
|
18
18
|
export type AddProductsToCartSnackbarMessageProps = {
|
|
19
19
|
errorSnackbar?: Omit<ErrorSnackbarProps, 'open'>
|
|
20
20
|
successSnackbar?: Omit<MessageSnackbarProps, 'open' | 'action'>
|
|
21
|
-
error?:
|
|
21
|
+
error?: ErrorLike | null
|
|
22
22
|
userErrors?: Pick<CartUserInputError, 'message'>[]
|
|
23
23
|
showSuccess: boolean
|
|
24
24
|
addedItems: string[]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApolloClient,
|
|
1
|
+
import type { ApolloClient, TypedDocumentNode } from '@graphcommerce/graphql'
|
|
2
2
|
import { gql } from '@graphcommerce/graphql'
|
|
3
3
|
import type { AttributeFrontendInputEnum, Exact } from '@graphcommerce/graphql-mesh'
|
|
4
4
|
import { magentoVersion } from '@graphcommerce/next-config/config'
|
|
@@ -32,7 +32,7 @@ const FilterInputTypesDocument = gql`
|
|
|
32
32
|
export type FilterTypes = Partial<Record<string, AttributeFrontendInputEnum>>
|
|
33
33
|
|
|
34
34
|
export async function getFilterTypes(
|
|
35
|
-
client: ApolloClient
|
|
35
|
+
client: ApolloClient,
|
|
36
36
|
isSearch: boolean = false,
|
|
37
37
|
): Promise<FilterTypes> {
|
|
38
38
|
if (magentoVersion >= 247) {
|
|
@@ -44,7 +44,7 @@ export async function getFilterTypes(
|
|
|
44
44
|
})
|
|
45
45
|
|
|
46
46
|
const typeMap: FilterTypes = Object.fromEntries(
|
|
47
|
-
filterNonNullableKeys(types.data
|
|
47
|
+
filterNonNullableKeys(types.data?.attributesList?.items ?? [], ['frontend_input'])
|
|
48
48
|
.map((i) => [i.code, i.frontend_input])
|
|
49
49
|
.filter(nonNullable),
|
|
50
50
|
)
|
|
@@ -55,7 +55,7 @@ export async function getFilterTypes(
|
|
|
55
55
|
const filterInputTypes = await client.query({ query: FilterInputTypesDocument })
|
|
56
56
|
|
|
57
57
|
const typeMap: FilterTypes = Object.fromEntries(
|
|
58
|
-
filterInputTypes.data?.__type
|
|
58
|
+
(filterInputTypes.data?.__type?.inputFields ?? [])
|
|
59
59
|
.map<[string, AttributeFrontendInputEnum] | undefined>((field) => {
|
|
60
60
|
if (field.type.name === 'FilterEqualTypeInput') return [field.name, 'SELECT']
|
|
61
61
|
if (field.type.name === 'FilterRangeTypeInput') return [field.name, 'PRICE']
|
|
@@ -33,7 +33,7 @@ export function useProductListApplyCategoryDefaults(
|
|
|
33
33
|
|
|
34
34
|
export async function productListApplyCategoryDefaults(
|
|
35
35
|
params: ProductListParams,
|
|
36
|
-
conf: StoreConfigQuery,
|
|
36
|
+
conf: StoreConfigQuery | undefined,
|
|
37
37
|
category:
|
|
38
38
|
| Promise<CategoryDefaultFragment | null | undefined>
|
|
39
39
|
| CategoryDefaultFragment
|
|
@@ -42,7 +42,7 @@ export async function productListApplyCategoryDefaults(
|
|
|
42
42
|
): Promise<ProductListQueryVariables>
|
|
43
43
|
export async function productListApplyCategoryDefaults(
|
|
44
44
|
params: ProductListParams | undefined,
|
|
45
|
-
conf: StoreConfigQuery,
|
|
45
|
+
conf: StoreConfigQuery | undefined,
|
|
46
46
|
category:
|
|
47
47
|
| Promise<CategoryDefaultFragment | null | undefined>
|
|
48
48
|
| CategoryDefaultFragment
|
|
@@ -52,11 +52,12 @@ export async function productListApplyCategoryDefaults(
|
|
|
52
52
|
if (!params) return params
|
|
53
53
|
|
|
54
54
|
const newParams = cloneDeep(params)
|
|
55
|
-
if (!newParams.pageSize) newParams.pageSize = conf
|
|
55
|
+
if (!newParams.pageSize) newParams.pageSize = conf?.storeConfig?.grid_per_page ?? 12
|
|
56
56
|
|
|
57
57
|
if (Object.keys(params.sort).length === 0) {
|
|
58
58
|
const categorySort = (await category)?.default_sort_by as keyof ProductListParams['sort']
|
|
59
|
-
const defaultSort = conf
|
|
59
|
+
const defaultSort = conf?.storeConfig
|
|
60
|
+
?.catalog_default_sort_by as keyof ProductListParams['sort']
|
|
60
61
|
if (categorySort) newParams.sort = { [categorySort]: 'ASC' }
|
|
61
62
|
else if (defaultSort) newParams.sort = { [defaultSort]: 'ASC' }
|
|
62
63
|
}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import type { ApolloClient
|
|
1
|
+
import type { ApolloClient } from '@graphcommerce/graphql'
|
|
2
2
|
import { limitSsg } from '@graphcommerce/next-config/config'
|
|
3
3
|
import type { GetStaticPathsResult } from 'next'
|
|
4
|
-
import type { ProductStaticPathsQuery } from './ProductStaticPaths.gql'
|
|
5
4
|
import { ProductStaticPathsDocument } from './ProductStaticPaths.gql'
|
|
6
5
|
|
|
7
6
|
type Return = GetStaticPathsResult<{ url: string }>
|
|
8
7
|
|
|
9
8
|
export type ProductTypenames = NonNullable<
|
|
10
|
-
NonNullable<
|
|
11
|
-
|
|
9
|
+
NonNullable<
|
|
10
|
+
NonNullable<
|
|
11
|
+
Awaited<ReturnType<typeof getProductStaticPaths>> extends Return
|
|
12
|
+
? Return['paths'][number]
|
|
13
|
+
: never
|
|
14
|
+
>
|
|
15
|
+
>
|
|
16
|
+
>
|
|
12
17
|
|
|
13
18
|
export async function getProductStaticPaths(
|
|
14
|
-
client: ApolloClient
|
|
19
|
+
client: ApolloClient,
|
|
15
20
|
locale: string,
|
|
16
21
|
options: { limit?: boolean } = { limit: limitSsg || false },
|
|
17
22
|
) {
|
|
@@ -19,10 +24,11 @@ export async function getProductStaticPaths(
|
|
|
19
24
|
query: ProductStaticPathsDocument,
|
|
20
25
|
variables: { currentPage: 1, pageSize: 100 },
|
|
21
26
|
})
|
|
22
|
-
const pages: Promise<ApolloQueryResult<ProductStaticPathsQuery>>[] = [query]
|
|
23
27
|
|
|
24
28
|
const { data } = await query
|
|
25
|
-
const totalPages = data
|
|
29
|
+
const totalPages = data?.products?.page_info?.total_pages ?? 1
|
|
30
|
+
|
|
31
|
+
const pages = [query]
|
|
26
32
|
|
|
27
33
|
if (totalPages > 1 && options.limit !== true) {
|
|
28
34
|
for (let i = 2; i <= totalPages; i++) {
|
|
@@ -36,7 +42,7 @@ export async function getProductStaticPaths(
|
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
const paths: Return['paths'] = (await Promise.all(pages))
|
|
39
|
-
.map((q) => q.data
|
|
45
|
+
.map((q) => q.data?.products?.items ?? [])
|
|
40
46
|
.flat(1)
|
|
41
47
|
.map((p) => ({ params: { url: `${p?.url_key}` }, locale }))
|
|
42
48
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApolloClient
|
|
1
|
+
import type { ApolloClient } from '@graphcommerce/graphql'
|
|
2
2
|
import { canonicalize, nonNullable } from '@graphcommerce/next-ui'
|
|
3
3
|
import { productLink } from '../../hooks/useProductLink'
|
|
4
4
|
import { ProductStaticPathsDocument } from './ProductStaticPaths.gql'
|
|
@@ -8,7 +8,7 @@ import { ProductStaticPathsDocument } from './ProductStaticPaths.gql'
|
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
10
|
export async function getSitemapPaths(
|
|
11
|
-
client: ApolloClient
|
|
11
|
+
client: ApolloClient,
|
|
12
12
|
ctx: { locale?: string; defaultLocale?: string },
|
|
13
13
|
pageSize: number,
|
|
14
14
|
) {
|
|
@@ -16,11 +16,11 @@ export async function getSitemapPaths(
|
|
|
16
16
|
const query = ProductStaticPathsDocument
|
|
17
17
|
|
|
18
18
|
const pageInfo = client.query({ query, variables: { currentPage: 1, pageSize } })
|
|
19
|
-
const total = (await pageInfo).data
|
|
19
|
+
const total = (await pageInfo).data?.products?.page_info?.total_pages || 0
|
|
20
20
|
|
|
21
21
|
const result = Array.from(Array(total).keys()).map(async (currentPage) => {
|
|
22
22
|
const res = await client.query({ query, variables: { currentPage: currentPage + 1, pageSize } })
|
|
23
|
-
return res.data
|
|
23
|
+
return res.data?.products?.items
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
const options = { locale, defaultLocale, pathname: '/', isLocaleDomain: false }
|
package/hooks/useProductList.ts
CHANGED
|
@@ -34,7 +34,7 @@ export const prefetchProductList = debounce(
|
|
|
34
34
|
variables: ProductListQueryVariables,
|
|
35
35
|
filtersVariables: ProductFiltersQueryVariables,
|
|
36
36
|
next: Next,
|
|
37
|
-
client: ApolloClient
|
|
37
|
+
client: ApolloClient,
|
|
38
38
|
shallow: boolean,
|
|
39
39
|
) => {
|
|
40
40
|
if (!shallow) return next(shallow)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-product",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "10.0.0-canary.
|
|
5
|
+
"version": "10.0.0-canary.72",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"typescript": "5.9.3"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@graphcommerce/ecommerce-ui": "^10.0.0-canary.
|
|
22
|
-
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.
|
|
23
|
-
"@graphcommerce/framer-next-pages": "^10.0.0-canary.
|
|
24
|
-
"@graphcommerce/framer-scroller": "^10.0.0-canary.
|
|
25
|
-
"@graphcommerce/graphql": "^10.0.0-canary.
|
|
26
|
-
"@graphcommerce/graphql-mesh": "^10.0.0-canary.
|
|
27
|
-
"@graphcommerce/image": "^10.0.0-canary.
|
|
28
|
-
"@graphcommerce/magento-cart": "^10.0.0-canary.
|
|
29
|
-
"@graphcommerce/magento-store": "^10.0.0-canary.
|
|
30
|
-
"@graphcommerce/next-ui": "^10.0.0-canary.
|
|
31
|
-
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.
|
|
32
|
-
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.
|
|
21
|
+
"@graphcommerce/ecommerce-ui": "^10.0.0-canary.72",
|
|
22
|
+
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.72",
|
|
23
|
+
"@graphcommerce/framer-next-pages": "^10.0.0-canary.72",
|
|
24
|
+
"@graphcommerce/framer-scroller": "^10.0.0-canary.72",
|
|
25
|
+
"@graphcommerce/graphql": "^10.0.0-canary.72",
|
|
26
|
+
"@graphcommerce/graphql-mesh": "^10.0.0-canary.72",
|
|
27
|
+
"@graphcommerce/image": "^10.0.0-canary.72",
|
|
28
|
+
"@graphcommerce/magento-cart": "^10.0.0-canary.72",
|
|
29
|
+
"@graphcommerce/magento-store": "^10.0.0-canary.72",
|
|
30
|
+
"@graphcommerce/next-ui": "^10.0.0-canary.72",
|
|
31
|
+
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.72",
|
|
32
|
+
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.72",
|
|
33
33
|
"@lingui/core": "^5",
|
|
34
34
|
"@lingui/macro": "^5",
|
|
35
35
|
"@lingui/react": "^5",
|