@graphcommerce/hygraph-dynamic-rows 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/lib/getAllHygraphDynamicRows.ts +5 -5
- package/lib/hygraphDynamicRows.ts +2 -2
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @graphcommerce/hygraph-dynamic-rows
|
|
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
|
## 10.0.0-canary.67
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { cacheFirst } from '@graphcommerce/graphql'
|
|
2
|
-
import type { ApolloClient
|
|
2
|
+
import type { ApolloClient } from '@apollo/client'
|
|
3
3
|
import type { AllDynamicRowsQuery } from '../graphql'
|
|
4
4
|
import { AllDynamicRowsDocument } from '../graphql'
|
|
5
5
|
|
|
6
6
|
type DynamicRows = AllDynamicRowsQuery['dynamicRows']
|
|
7
7
|
|
|
8
8
|
export async function getAllHygraphDynamicRows(
|
|
9
|
-
client: ApolloClient
|
|
9
|
+
client: ApolloClient,
|
|
10
10
|
options: { pageSize?: number } = {},
|
|
11
11
|
) {
|
|
12
12
|
const { pageSize = 100 } = options
|
|
@@ -17,10 +17,10 @@ export async function getAllHygraphDynamicRows(
|
|
|
17
17
|
fetchPolicy: cacheFirst(client),
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
const pages: Promise<
|
|
20
|
+
const pages: Promise<ApolloClient.QueryResult<AllDynamicRowsQuery>>[] = [query]
|
|
21
21
|
|
|
22
22
|
const { data } = await query
|
|
23
|
-
const totalPages = Math.ceil(data
|
|
23
|
+
const totalPages = Math.ceil((data?.pagesConnection.aggregate.count ?? 0) / pageSize) ?? 1
|
|
24
24
|
if (totalPages > 1) {
|
|
25
25
|
for (let i = 2; i <= totalPages; i++) {
|
|
26
26
|
pages.push(
|
|
@@ -34,7 +34,7 @@ export async function getAllHygraphDynamicRows(
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const dynamicRows: DynamicRows = (await Promise.all(pages))
|
|
37
|
-
.map((q) => q.data
|
|
37
|
+
.map((q) => q.data?.dynamicRows ?? [])
|
|
38
38
|
.flat(1)
|
|
39
39
|
.map((row) => ({
|
|
40
40
|
id: row.id,
|
|
@@ -89,7 +89,7 @@ type Page = HygraphPagesQuery['pages'][number]
|
|
|
89
89
|
* - Implements an alias sytem to merge the content of multiple pages.
|
|
90
90
|
*/
|
|
91
91
|
export async function hygraphDynamicRows(
|
|
92
|
-
client: ApolloClient
|
|
92
|
+
client: ApolloClient,
|
|
93
93
|
pageQuery: Promise<{ data: HygraphPagesQuery }>,
|
|
94
94
|
url: string,
|
|
95
95
|
cached: boolean,
|
|
@@ -119,7 +119,7 @@ export async function hygraphDynamicRows(
|
|
|
119
119
|
// Create a copy of the content array.
|
|
120
120
|
const content = [...(page?.content ?? [])]
|
|
121
121
|
|
|
122
|
-
dynamicResult?.data
|
|
122
|
+
dynamicResult?.data?.dynamicRows.forEach((dynamicRow) => {
|
|
123
123
|
const { placement, target, rows } = dynamicRow
|
|
124
124
|
if (!rows) return
|
|
125
125
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/hygraph-dynamic-rows",
|
|
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": {
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.
|
|
16
|
-
"@graphcommerce/graphql": "^10.0.0-canary.
|
|
17
|
-
"@graphcommerce/hygraph-ui": "^10.0.0-canary.
|
|
18
|
-
"@graphcommerce/image": "^10.0.0-canary.
|
|
19
|
-
"@graphcommerce/next-ui": "^10.0.0-canary.
|
|
20
|
-
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.
|
|
21
|
-
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.72",
|
|
16
|
+
"@graphcommerce/graphql": "^10.0.0-canary.72",
|
|
17
|
+
"@graphcommerce/hygraph-ui": "^10.0.0-canary.72",
|
|
18
|
+
"@graphcommerce/image": "^10.0.0-canary.72",
|
|
19
|
+
"@graphcommerce/next-ui": "^10.0.0-canary.72",
|
|
20
|
+
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.72",
|
|
21
|
+
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.72",
|
|
22
22
|
"@mui/material": "^7.0.0",
|
|
23
23
|
"next": "*",
|
|
24
24
|
"react": "^19.2.0",
|