@graphcommerce/hygraph-dynamic-rows 8.1.0-canary.9 → 9.0.0-canary.101

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 CHANGED
@@ -1,5 +1,201 @@
1
1
  # @graphcommerce/hygraph-dynamic-rows
2
2
 
3
+ ## 9.0.0-canary.101
4
+
5
+ ## 9.0.0-canary.100
6
+
7
+ ## 9.0.0-canary.99
8
+
9
+ ## 9.0.0-canary.98
10
+
11
+ ## 9.0.0-canary.97
12
+
13
+ ## 9.0.0-canary.96
14
+
15
+ ## 9.0.0-canary.95
16
+
17
+ ## 9.0.0-canary.94
18
+
19
+ ## 9.0.0-canary.93
20
+
21
+ ## 9.0.0-canary.92
22
+
23
+ ## 9.0.0-canary.91
24
+
25
+ ## 9.0.0-canary.90
26
+
27
+ ## 9.0.0-canary.89
28
+
29
+ ## 9.0.0-canary.88
30
+
31
+ ## 9.0.0-canary.87
32
+
33
+ ## 9.0.0-canary.86
34
+
35
+ ## 9.0.0-canary.85
36
+
37
+ ## 9.0.0-canary.84
38
+
39
+ ## 9.0.0-canary.83
40
+
41
+ ## 9.0.0-canary.82
42
+
43
+ ## 9.0.0-canary.81
44
+
45
+ ## 9.0.0-canary.80
46
+
47
+ ## 9.0.0-canary.79
48
+
49
+ ## 9.0.0-canary.78
50
+
51
+ ## 9.0.0-canary.77
52
+
53
+ ## 9.0.0-canary.76
54
+
55
+ ### Minor Changes
56
+
57
+ - [#2318](https://github.com/graphcommerce-org/graphcommerce/pull/2318) [`886837f`](https://github.com/graphcommerce-org/graphcommerce/commit/886837ff44d95404512716dbb9b2272c38b9ad27) - Terminate row field on DynamicRows model ([@JoshuaS98](https://github.com/JoshuaS98))
58
+
59
+ ## 9.0.0-canary.75
60
+
61
+ ## 9.0.0-canary.74
62
+
63
+ ## 9.0.0-canary.73
64
+
65
+ ## 9.0.0-canary.72
66
+
67
+ ## 9.0.0-canary.71
68
+
69
+ ## 9.0.0-canary.70
70
+
71
+ ## 9.0.0-canary.69
72
+
73
+ ## 9.0.0-canary.68
74
+
75
+ ## 9.0.0-canary.67
76
+
77
+ ## 9.0.0-canary.66
78
+
79
+ ## 9.0.0-canary.65
80
+
81
+ ## 9.0.0-canary.64
82
+
83
+ ## 9.0.0-canary.63
84
+
85
+ ## 9.0.0-canary.62
86
+
87
+ ## 9.0.0-canary.61
88
+
89
+ ## 9.0.0-canary.60
90
+
91
+ ### Patch Changes
92
+
93
+ - [#2331](https://github.com/graphcommerce-org/graphcommerce/pull/2331) [`702bfc9`](https://github.com/graphcommerce-org/graphcommerce/commit/702bfc93566c9745546988e57988431d5d4d8cb0) - Moved plugins to new format ([@paales](https://github.com/paales))
94
+
95
+ ## 9.0.0-canary.59
96
+
97
+ ## 9.0.0-canary.58
98
+
99
+ ## 9.0.0-canary.57
100
+
101
+ ## 9.0.0-canary.56
102
+
103
+ ## 9.0.0-canary.55
104
+
105
+ ## 9.0.0-canary.54
106
+
107
+ ## 8.1.0-canary.53
108
+
109
+ ## 8.1.0-canary.52
110
+
111
+ ## 8.1.0-canary.51
112
+
113
+ ## 8.1.0-canary.50
114
+
115
+ ## 8.1.0-canary.49
116
+
117
+ ## 8.1.0-canary.48
118
+
119
+ ## 8.1.0-canary.47
120
+
121
+ ## 8.1.0-canary.46
122
+
123
+ ## 8.1.0-canary.45
124
+
125
+ ## 8.1.0-canary.44
126
+
127
+ ## 8.1.0-canary.43
128
+
129
+ ## 8.1.0-canary.42
130
+
131
+ ## 8.1.0-canary.41
132
+
133
+ ## 8.1.0-canary.40
134
+
135
+ ## 8.1.0-canary.39
136
+
137
+ ## 8.1.0-canary.38
138
+
139
+ ## 8.1.0-canary.37
140
+
141
+ ## 8.1.0-canary.36
142
+
143
+ ## 8.1.0-canary.35
144
+
145
+ ## 8.1.0-canary.34
146
+
147
+ ## 8.1.0-canary.33
148
+
149
+ ## 8.1.0-canary.32
150
+
151
+ ## 8.1.0-canary.31
152
+
153
+ ## 8.1.0-canary.30
154
+
155
+ ## 8.1.0-canary.29
156
+
157
+ ## 8.1.0-canary.28
158
+
159
+ ## 8.1.0-canary.27
160
+
161
+ ## 8.1.0-canary.26
162
+
163
+ ## 8.1.0-canary.25
164
+
165
+ ## 8.1.0-canary.24
166
+
167
+ ## 8.1.0-canary.23
168
+
169
+ ## 8.1.0-canary.22
170
+
171
+ ## 8.1.0-canary.21
172
+
173
+ ## 8.1.0-canary.20
174
+
175
+ ## 8.1.0-canary.19
176
+
177
+ ## 8.1.0-canary.18
178
+
179
+ ## 8.1.0-canary.17
180
+
181
+ ## 8.1.0-canary.16
182
+
183
+ ## 8.1.0-canary.15
184
+
185
+ ## 8.1.0-canary.14
186
+
187
+ ## 8.1.0-canary.13
188
+
189
+ ### Patch Changes
190
+
191
+ - [#2268](https://github.com/graphcommerce-org/graphcommerce/pull/2268) [`8ffe2d5`](https://github.com/graphcommerce-org/graphcommerce/commit/8ffe2d5d1b040797ee4987d7740de5fdeadd4f72) - Fix for non extensible object error in Dynamic Row package ([@JoshuaS98](https://github.com/JoshuaS98))
192
+
193
+ ## 8.1.0-canary.12
194
+
195
+ ## 8.1.0-canary.11
196
+
197
+ ## 8.1.0-canary.10
198
+
3
199
  ## 8.1.0-canary.9
4
200
 
5
201
  ## 8.1.0-canary.8
@@ -24,8 +220,7 @@
24
220
 
25
221
  ### Patch Changes
26
222
 
27
- - [#2238](https://github.com/graphcommerce-org/graphcommerce/pull/2238) [`db86432`](https://github.com/graphcommerce-org/graphcommerce/commit/db864324277fd5fb680c66eaa87d211cd7be4905) - Changed query limit to 100 from a 1000 on HygraphAllPages and AllDynamicRows query and added pagination.
28
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
223
+ - [#2238](https://github.com/graphcommerce-org/graphcommerce/pull/2238) [`db86432`](https://github.com/graphcommerce-org/graphcommerce/commit/db864324277fd5fb680c66eaa87d211cd7be4905) - Changed query limit to 100 from a 1000 on HygraphAllPages and AllDynamicRows query and added pagination. ([@Jessevdpoel](https://github.com/Jessevdpoel))
29
224
 
30
225
  ## 8.0.5-canary.10
31
226
 
@@ -33,8 +228,7 @@
33
228
 
34
229
  ### Patch Changes
35
230
 
36
- - [#2238](https://github.com/graphcommerce-org/graphcommerce/pull/2238) [`db86432`](https://github.com/graphcommerce-org/graphcommerce/commit/db864324277fd5fb680c66eaa87d211cd7be4905) - Changed query limit to 100 from a 1000 on HygraphAllPages and AllDynamicRows query and added pagination.
37
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
231
+ - [#2238](https://github.com/graphcommerce-org/graphcommerce/pull/2238) [`db86432`](https://github.com/graphcommerce-org/graphcommerce/commit/db864324277fd5fb680c66eaa87d211cd7be4905) - Changed query limit to 100 from a 1000 on HygraphAllPages and AllDynamicRows query and added pagination. ([@Jessevdpoel](https://github.com/Jessevdpoel))
38
232
 
39
233
  ## 8.0.5-canary.8
40
234
 
@@ -102,11 +296,9 @@
102
296
 
103
297
  ### Patch Changes
104
298
 
105
- - [`df385d9`](https://github.com/graphcommerce-org/graphcommerce/commit/df385d9a2e724715e0f08cc13b1bef6748b38b82) - Allow muiltiple rows for each Dynamic Row entry in Hygraph
106
- ([@JoshuaS98](https://github.com/JoshuaS98))
299
+ - [`df385d9`](https://github.com/graphcommerce-org/graphcommerce/commit/df385d9a2e724715e0f08cc13b1bef6748b38b82) - Allow muiltiple rows for each Dynamic Row entry in Hygraph ([@JoshuaS98](https://github.com/JoshuaS98))
107
300
 
108
- - [#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
109
- ([@paales](https://github.com/paales))
301
+ - [#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 ([@paales](https://github.com/paales))
110
302
 
111
303
  ## 8.0.0-canary.100
112
304
 
@@ -116,8 +308,7 @@
116
308
 
117
309
  ### Patch Changes
118
310
 
119
- - [#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
120
- ([@paales](https://github.com/paales))
311
+ - [#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 ([@paales](https://github.com/paales))
121
312
 
122
313
  ## 8.0.0-canary.97
123
314
 
@@ -1,28 +1,15 @@
1
- fragment DynamicRow on DynamicRow @injectable {
1
+ fragment DynamicRow on DynamicRow {
2
2
  placement
3
3
  target {
4
4
  ... on Node {
5
5
  id
6
6
  }
7
7
  }
8
-
9
- row {
10
- __typename
11
- ... on Node {
12
- id
13
- }
14
-
15
- ...RowColumnOne
16
- ...RowQuote
17
- ...RowLinks
18
- }
19
-
20
8
  rows {
21
9
  __typename
22
10
  ... on Node {
23
11
  id
24
12
  }
25
-
26
13
  ...RowColumnOne
27
14
  ...RowQuote
28
15
  ...RowLinks
@@ -1,4 +1,5 @@
1
1
  import type { ApolloClient, NormalizedCacheObject, ApolloQueryResult } from '@apollo/client'
2
+ import { cacheFirst } from '@graphcommerce/graphql'
2
3
  import { AllDynamicRowsDocument, AllDynamicRowsQuery } from '../graphql'
3
4
 
4
5
  type DynamicRows = AllDynamicRowsQuery['dynamicRows']
@@ -8,10 +9,11 @@ export async function getAllHygraphDynamicRows(
8
9
  options: { pageSize?: number } = {},
9
10
  ) {
10
11
  const { pageSize = 100 } = options
12
+
11
13
  const query = client.query({
12
14
  query: AllDynamicRowsDocument,
13
15
  variables: { first: pageSize },
14
- fetchPolicy: process.env.NODE_ENV !== 'development' ? 'cache-first' : undefined,
16
+ fetchPolicy: cacheFirst(client),
15
17
  })
16
18
 
17
19
  const pages: Promise<ApolloQueryResult<AllDynamicRowsQuery>>[] = [query]
@@ -24,7 +26,7 @@ export async function getAllHygraphDynamicRows(
24
26
  client.query({
25
27
  query: AllDynamicRowsDocument,
26
28
  variables: { first: pageSize, skip: pageSize * (i - 1) },
27
- fetchPolicy: process.env.NODE_ENV !== 'development' ? 'cache-first' : undefined,
29
+ fetchPolicy: cacheFirst(client),
28
30
  }),
29
31
  )
30
32
  }
@@ -1,5 +1,5 @@
1
1
  import { HygraphPagesQuery } from '@graphcommerce/graphcms-ui'
2
- import { ApolloClient, NormalizedCacheObject } from '@graphcommerce/graphql'
2
+ import { ApolloClient, NormalizedCacheObject, cacheFirst } from '@graphcommerce/graphql'
3
3
  import {
4
4
  ConditionTextFragment,
5
5
  ConditionNumberFragment,
@@ -94,8 +94,7 @@ export async function hygraphDynamicRows(
94
94
  cached: boolean,
95
95
  additionalProperties?: Promise<object> | object,
96
96
  ): Promise<{ data: HygraphPagesQuery }> {
97
- const alwaysCache = process.env.NODE_ENV !== 'development' ? 'cache-first' : undefined
98
- const fetchPolicy = cached ? alwaysCache : undefined
97
+ const fetchPolicy = cached ? cacheFirst(client) : undefined
99
98
 
100
99
  const allRoutes = await getAllHygraphDynamicRows(client)
101
100
 
@@ -117,25 +116,22 @@ export async function hygraphDynamicRows(
117
116
  const page = pageResult.data.pages[0] as Page | undefined
118
117
 
119
118
  // Create a copy of the content array.
120
- const content = page?.content ?? []
119
+ const content = [...(page?.content ?? [])]
121
120
 
122
121
  dynamicResult?.data.dynamicRows.forEach((dynamicRow) => {
123
- const { placement, target, rows, row } = dynamicRow
124
- if (!rows && !row) return
125
-
126
- const rowsToMerge = rows
127
- if (row && rows.length === 0) rowsToMerge.push(row)
122
+ const { placement, target, rows } = dynamicRow
123
+ if (!rows) return
128
124
 
129
125
  if (!target) {
130
- if (placement === 'BEFORE') content.unshift(...rowsToMerge)
131
- else content.push(...rowsToMerge)
126
+ if (placement === 'BEFORE') content.unshift(...rows)
127
+ else content.push(...rows)
132
128
  return
133
129
  }
134
130
 
135
131
  const targetIdx = content.findIndex((c) => c.id === target.id)
136
- if (placement === 'BEFORE') content.splice(targetIdx, 0, ...rowsToMerge)
137
- if (placement === 'AFTER') content.splice(targetIdx + 1, 0, ...rowsToMerge)
138
- if (placement === 'REPLACE') content.splice(targetIdx, 1, ...rowsToMerge)
132
+ if (placement === 'BEFORE') content.splice(targetIdx, 0, ...rows)
133
+ if (placement === 'AFTER') content.splice(targetIdx + 1, 0, ...rows)
134
+ if (placement === 'REPLACE') content.splice(targetIdx, 1, ...rows)
139
135
  })
140
136
 
141
137
  if (!content.length) return pageResult
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": "8.1.0-canary.9",
5
+ "version": "9.0.0-canary.101",
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": "^8.1.0-canary.9",
16
- "@graphcommerce/graphcms-ui": "^8.1.0-canary.9",
17
- "@graphcommerce/graphql": "^8.1.0-canary.9",
18
- "@graphcommerce/image": "^8.1.0-canary.9",
19
- "@graphcommerce/next-ui": "^8.1.0-canary.9",
20
- "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.9",
21
- "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.9",
15
+ "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.101",
16
+ "@graphcommerce/graphcms-ui": "^9.0.0-canary.101",
17
+ "@graphcommerce/graphql": "^9.0.0-canary.101",
18
+ "@graphcommerce/image": "^9.0.0-canary.101",
19
+ "@graphcommerce/next-ui": "^9.0.0-canary.101",
20
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.101",
21
+ "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.101",
22
22
  "@mui/material": "^5.10.16",
23
23
  "next": "*",
24
24
  "react": "^18.2.0",
@@ -1,11 +1,13 @@
1
- import type { hygraphPageContent } from '@graphcommerce/graphcms-ui'
2
- import type { MethodPlugin } from '@graphcommerce/next-config'
1
+ import type { hygraphPageContent as hygraphPageContentType } from '@graphcommerce/graphcms-ui'
2
+ import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config'
3
3
  import { hygraphDynamicRows } from '../lib/hygraphDynamicRows'
4
4
 
5
- export const func = 'hygraphPageContent'
6
- export const exported = '@graphcommerce/graphcms-ui'
5
+ export const config: PluginConfig = {
6
+ type: 'function',
7
+ module: '@graphcommerce/graphcms-ui',
8
+ }
7
9
 
8
- const hygraphDynamicRowsPageContent: MethodPlugin<typeof hygraphPageContent> = (
10
+ export const hygraphPageContent: FunctionPlugin<typeof hygraphPageContentType> = (
9
11
  prev,
10
12
  client,
11
13
  url,
@@ -15,5 +17,3 @@ const hygraphDynamicRowsPageContent: MethodPlugin<typeof hygraphPageContent> = (
15
17
  const pageQuery = prev(client, url, additionalProperties, cached)
16
18
  return hygraphDynamicRows(client, pageQuery, url, cached, additionalProperties)
17
19
  }
18
-
19
- export const plugin = hygraphDynamicRowsPageContent