@graphcommerce/hygraph-dynamic-rows 7.1.0-canary.8 → 8.0.0-canary.100
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 +181 -0
- package/graphql/DynamicRow.graphql +11 -0
- package/lib/hygraphDynamicRows.ts +32 -15
- package/package.json +9 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,186 @@
|
|
|
1
1
|
# @graphcommerce/hygraph-dynamic-rows
|
|
2
2
|
|
|
3
|
+
## 8.0.0-canary.100
|
|
4
|
+
|
|
5
|
+
## 8.0.0-canary.99
|
|
6
|
+
|
|
7
|
+
## 8.0.0-canary.98
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#2182](https://github.com/graphcommerce-org/graphcommerce/pull/2182) [`a93c312`](https://github.com/graphcommerce-org/graphcommerce/commit/a93c312b9d6e0d6cc102b49cc3ad02953200a1f6) - Dynamic rows would break page rendering if there was a dynamic row but no page returned
|
|
12
|
+
([@paales](https://github.com/paales))
|
|
13
|
+
|
|
14
|
+
## 8.0.0-canary.97
|
|
15
|
+
|
|
16
|
+
## 8.0.0-canary.96
|
|
17
|
+
|
|
18
|
+
## 8.0.0-canary.95
|
|
19
|
+
|
|
20
|
+
## 8.0.0-canary.94
|
|
21
|
+
|
|
22
|
+
## 8.0.0-canary.93
|
|
23
|
+
|
|
24
|
+
## 8.0.0-canary.92
|
|
25
|
+
|
|
26
|
+
## 8.0.0-canary.91
|
|
27
|
+
|
|
28
|
+
## 8.0.0-canary.90
|
|
29
|
+
|
|
30
|
+
## 8.0.0-canary.89
|
|
31
|
+
|
|
32
|
+
## 8.0.0-canary.88
|
|
33
|
+
|
|
34
|
+
## 8.0.0-canary.87
|
|
35
|
+
|
|
36
|
+
## 8.0.0-canary.86
|
|
37
|
+
|
|
38
|
+
## 8.0.0-canary.85
|
|
39
|
+
|
|
40
|
+
## 8.0.0-canary.84
|
|
41
|
+
|
|
42
|
+
## 8.0.0-canary.83
|
|
43
|
+
|
|
44
|
+
## 8.0.0-canary.82
|
|
45
|
+
|
|
46
|
+
## 8.0.0-canary.81
|
|
47
|
+
|
|
48
|
+
## 8.0.0-canary.80
|
|
49
|
+
|
|
50
|
+
## 8.0.0-canary.79
|
|
51
|
+
|
|
52
|
+
## 8.0.0-canary.78
|
|
53
|
+
|
|
54
|
+
## 8.0.0-canary.77
|
|
55
|
+
|
|
56
|
+
## 8.0.0-canary.76
|
|
57
|
+
|
|
58
|
+
## 8.0.0-canary.75
|
|
59
|
+
|
|
60
|
+
## 8.0.0-canary.74
|
|
61
|
+
|
|
62
|
+
## 8.0.0-canary.73
|
|
63
|
+
|
|
64
|
+
## 8.0.0-canary.72
|
|
65
|
+
|
|
66
|
+
## 8.0.0-canary.71
|
|
67
|
+
|
|
68
|
+
## 8.0.0-canary.70
|
|
69
|
+
|
|
70
|
+
## 8.0.0-canary.69
|
|
71
|
+
|
|
72
|
+
## 7.1.0-canary.68
|
|
73
|
+
|
|
74
|
+
## 7.1.0-canary.67
|
|
75
|
+
|
|
76
|
+
## 7.1.0-canary.66
|
|
77
|
+
|
|
78
|
+
## 7.1.0-canary.65
|
|
79
|
+
|
|
80
|
+
## 7.1.0-canary.64
|
|
81
|
+
|
|
82
|
+
## 7.1.0-canary.63
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- [`df385d9a2`](https://github.com/graphcommerce-org/graphcommerce/commit/df385d9a2e724715e0f08cc13b1bef6748b38b82) - enabled multiple rows per Dynamic Row ([@JoshuaS98](https://github.com/JoshuaS98))
|
|
87
|
+
|
|
88
|
+
## 7.1.0-canary.62
|
|
89
|
+
|
|
90
|
+
## 7.1.0-canary.61
|
|
91
|
+
|
|
92
|
+
## 7.1.0-canary.60
|
|
93
|
+
|
|
94
|
+
## 7.1.0-canary.59
|
|
95
|
+
|
|
96
|
+
## 7.1.0-canary.58
|
|
97
|
+
|
|
98
|
+
## 7.1.0-canary.57
|
|
99
|
+
|
|
100
|
+
## 7.1.0-canary.56
|
|
101
|
+
|
|
102
|
+
## 7.1.0-canary.55
|
|
103
|
+
|
|
104
|
+
## 7.1.0-canary.54
|
|
105
|
+
|
|
106
|
+
## 7.1.0-canary.53
|
|
107
|
+
|
|
108
|
+
## 7.1.0-canary.52
|
|
109
|
+
|
|
110
|
+
## 7.1.0-canary.51
|
|
111
|
+
|
|
112
|
+
## 7.1.0-canary.50
|
|
113
|
+
|
|
114
|
+
## 7.1.0-canary.49
|
|
115
|
+
|
|
116
|
+
## 7.1.0-canary.48
|
|
117
|
+
|
|
118
|
+
## 7.1.0-canary.47
|
|
119
|
+
|
|
120
|
+
## 7.1.0-canary.46
|
|
121
|
+
|
|
122
|
+
## 7.1.0-canary.45
|
|
123
|
+
|
|
124
|
+
## 7.1.0-canary.38
|
|
125
|
+
|
|
126
|
+
## 7.1.0-canary.37
|
|
127
|
+
|
|
128
|
+
## 7.1.0-canary.36
|
|
129
|
+
|
|
130
|
+
## 7.1.0-canary.35
|
|
131
|
+
|
|
132
|
+
## 7.1.0-canary.34
|
|
133
|
+
|
|
134
|
+
## 7.1.0-canary.33
|
|
135
|
+
|
|
136
|
+
## 7.1.0-canary.32
|
|
137
|
+
|
|
138
|
+
## 7.1.0-canary.31
|
|
139
|
+
|
|
140
|
+
## 7.1.0-canary.30
|
|
141
|
+
|
|
142
|
+
## 7.1.0-canary.29
|
|
143
|
+
|
|
144
|
+
## 7.1.0-canary.28
|
|
145
|
+
|
|
146
|
+
## 7.1.0-canary.27
|
|
147
|
+
|
|
148
|
+
## 7.1.0-canary.26
|
|
149
|
+
|
|
150
|
+
## 7.1.0-canary.25
|
|
151
|
+
|
|
152
|
+
## 7.1.0-canary.24
|
|
153
|
+
|
|
154
|
+
## 7.1.0-canary.23
|
|
155
|
+
|
|
156
|
+
## 7.1.0-canary.22
|
|
157
|
+
|
|
158
|
+
## 7.1.0-canary.21
|
|
159
|
+
|
|
160
|
+
## 7.1.0-canary.20
|
|
161
|
+
|
|
162
|
+
## 7.1.0-canary.19
|
|
163
|
+
|
|
164
|
+
## 7.1.0-canary.18
|
|
165
|
+
|
|
166
|
+
## 7.1.0-canary.17
|
|
167
|
+
|
|
168
|
+
## 7.1.0-canary.16
|
|
169
|
+
|
|
170
|
+
## 7.1.0-canary.15
|
|
171
|
+
|
|
172
|
+
## 7.1.0-canary.14
|
|
173
|
+
|
|
174
|
+
## 7.1.0-canary.13
|
|
175
|
+
|
|
176
|
+
## 7.1.0-canary.12
|
|
177
|
+
|
|
178
|
+
## 7.1.0-canary.11
|
|
179
|
+
|
|
180
|
+
## 7.1.0-canary.10
|
|
181
|
+
|
|
182
|
+
## 7.1.0-canary.9
|
|
183
|
+
|
|
3
184
|
## 7.1.0-canary.8
|
|
4
185
|
|
|
5
186
|
## 7.0.2-canary.7
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* - Boven de product description zetten? in rowrenderer zetten
|
|
3
|
-
* - Hoe gaan we dit optioneel maken?
|
|
4
|
-
* - Hoe gaan we dit upgradebaar maken? management sdk
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
import { HygraphPagesQuery } from '@graphcommerce/graphcms-ui'
|
|
8
2
|
import { ApolloClient, NormalizedCacheObject } from '@graphcommerce/graphql'
|
|
9
3
|
import {
|
|
@@ -85,6 +79,8 @@ function matchCondition(
|
|
|
85
79
|
return false
|
|
86
80
|
}
|
|
87
81
|
|
|
82
|
+
type Page = HygraphPagesQuery['pages'][number]
|
|
83
|
+
|
|
88
84
|
/**
|
|
89
85
|
* Fetch the page content for the given urls.
|
|
90
86
|
*
|
|
@@ -119,27 +115,48 @@ export async function hygraphDynamicRows(
|
|
|
119
115
|
|
|
120
116
|
const [pageResult, dynamicResult] = await Promise.all([pageQuery, dynamicRows])
|
|
121
117
|
|
|
118
|
+
const page = pageResult.data.pages[0] as Page | undefined
|
|
119
|
+
|
|
122
120
|
// Create a copy of the content array.
|
|
123
|
-
const content =
|
|
121
|
+
const content = page?.content ?? []
|
|
124
122
|
|
|
125
123
|
dynamicResult?.data.dynamicRows.forEach((dynamicRow) => {
|
|
126
|
-
const { placement, target, row } = dynamicRow
|
|
127
|
-
if (!row) return
|
|
124
|
+
const { placement, target, rows, row } = dynamicRow
|
|
125
|
+
if (!rows && !row) return
|
|
126
|
+
|
|
127
|
+
const rowsToMerge = rows
|
|
128
|
+
if (row && rows.length === 0) rowsToMerge.push(row)
|
|
128
129
|
|
|
129
130
|
if (!target) {
|
|
130
|
-
if (placement === 'BEFORE') content.unshift(
|
|
131
|
-
else content.push(
|
|
131
|
+
if (placement === 'BEFORE') content.unshift(...rowsToMerge)
|
|
132
|
+
else content.push(...rowsToMerge)
|
|
132
133
|
return
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
const targetIdx = content.findIndex((c) => c.id === target.id)
|
|
136
|
-
if (placement === 'BEFORE') content.splice(targetIdx, 0,
|
|
137
|
-
if (placement === 'AFTER') content.splice(targetIdx + 1, 0,
|
|
138
|
-
if (placement === 'REPLACE') content.splice(targetIdx, 1,
|
|
137
|
+
if (placement === 'BEFORE') content.splice(targetIdx, 0, ...rowsToMerge)
|
|
138
|
+
if (placement === 'AFTER') content.splice(targetIdx + 1, 0, ...rowsToMerge)
|
|
139
|
+
if (placement === 'REPLACE') content.splice(targetIdx, 1, ...rowsToMerge)
|
|
139
140
|
})
|
|
140
141
|
|
|
141
142
|
if (!content.length) return pageResult
|
|
142
143
|
|
|
144
|
+
const dynamicPage: Page = {
|
|
145
|
+
id: 'dynamic-page',
|
|
146
|
+
__typename: 'Page',
|
|
147
|
+
metaRobots: 'INDEX_FOLLOW',
|
|
148
|
+
metaTitle: '',
|
|
149
|
+
metaDescription: '',
|
|
150
|
+
url: '',
|
|
151
|
+
content: [],
|
|
152
|
+
relatedPages: [],
|
|
153
|
+
}
|
|
154
|
+
|
|
143
155
|
// Return the merged page result.
|
|
144
|
-
return {
|
|
156
|
+
return {
|
|
157
|
+
data: {
|
|
158
|
+
...pageResult.data,
|
|
159
|
+
pages: [{ ...dynamicPage, ...page, content }],
|
|
160
|
+
},
|
|
161
|
+
}
|
|
145
162
|
}
|
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": "
|
|
5
|
+
"version": "8.0.0-canary.100",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -11,20 +11,16 @@
|
|
|
11
11
|
"project": "./tsconfig.json"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "7.1.0-canary.8",
|
|
16
|
-
"@graphcommerce/prettier-config-pwa": "7.1.0-canary.8",
|
|
17
|
-
"@graphcommerce/typescript-config-pwa": "7.1.0-canary.8"
|
|
18
|
-
},
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"@graphcommerce/graphql": "7.1.0-canary.8",
|
|
21
|
-
"@graphcommerce/image": "7.1.0-canary.8",
|
|
22
|
-
"@graphcommerce/next-ui": "7.1.0-canary.8",
|
|
23
|
-
"@graphcommerce/graphcms-ui": "7.1.0-canary.8"
|
|
24
|
-
},
|
|
25
14
|
"peerDependencies": {
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^8.0.0-canary.100",
|
|
16
|
+
"@graphcommerce/graphcms-ui": "^8.0.0-canary.100",
|
|
17
|
+
"@graphcommerce/graphql": "^8.0.0-canary.100",
|
|
18
|
+
"@graphcommerce/image": "^8.0.0-canary.100",
|
|
19
|
+
"@graphcommerce/next-ui": "^8.0.0-canary.100",
|
|
20
|
+
"@graphcommerce/prettier-config-pwa": "^8.0.0-canary.100",
|
|
21
|
+
"@graphcommerce/typescript-config-pwa": "^8.0.0-canary.100",
|
|
26
22
|
"@mui/material": "^5.10.16",
|
|
27
|
-
"next": "
|
|
23
|
+
"next": "*",
|
|
28
24
|
"react": "^18.2.0",
|
|
29
25
|
"react-dom": "^18.2.0"
|
|
30
26
|
}
|