@graphcommerce/graphql 7.0.0-canary.21 → 7.0.1-canary.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,208 @@
1
1
  # Change Log
2
2
 
3
- ## 7.0.0-canary.21
3
+ ## 7.0.1-canary.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2047](https://github.com/graphcommerce-org/graphcommerce/pull/2047) [`136580b39`](https://github.com/graphcommerce-org/graphcommerce/commit/136580b39e3cffdd07e3fa087e049bd532c3e8f1) - Updated all dependencies to the latest version where possible. ([@paales](https://github.com/paales))
8
+
9
+ ## 7.0.0
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1960](https://github.com/graphcommerce-org/graphcommerce/pull/1960) [`f78caf5a8`](https://github.com/graphcommerce-org/graphcommerce/commit/f78caf5a83683f1ae4b901fb94bd22d50943fa2f) - Updated packages: `next`, `@apollo/client`, `react-hook-form`, `@emotion/*`, `@lingui/*`, `@mui/*` and various others. ([@paales](https://github.com/paales))
14
+
15
+ - [#2012](https://github.com/graphcommerce-org/graphcommerce/pull/2012) [`1dbb3ae13`](https://github.com/graphcommerce-org/graphcommerce/commit/1dbb3ae13553992ee1ed77f375375560f28c418c) - Upgrade graphql to 16.7.1, add graphql as peer dependency ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
16
+
17
+ - [#2031](https://github.com/graphcommerce-org/graphcommerce/pull/2031) [`4d8fc9e99`](https://github.com/graphcommerce-org/graphcommerce/commit/4d8fc9e998fc9361282833316ec9564da0644ed6) - Eslint fixes and suppress accepted warnings ([@paales](https://github.com/paales))
18
+
19
+ - [#1915](https://github.com/graphcommerce-org/graphcommerce/pull/1915) [`f4a8c3881`](https://github.com/graphcommerce-org/graphcommerce/commit/f4a8c388183e17c52e7f66536c5448749f494d7f) - Moved the injection of the links to plugins ([@paales](https://github.com/paales))
20
+
21
+ - [#1960](https://github.com/graphcommerce-org/graphcommerce/pull/1960) [`86e14569b`](https://github.com/graphcommerce-org/graphcommerce/commit/86e14569b1f68f73be7f93b614e36b382c5debff) - Updated to the latest release of GraphQL codegen and solve compatibility issues with our own generator ([@paales](https://github.com/paales))
22
+
23
+ - [#1942](https://github.com/graphcommerce-org/graphcommerce/pull/1942) [`df2b3efb2`](https://github.com/graphcommerce-org/graphcommerce/commit/df2b3efb2f906232a302218678c1524753c5a32c) - Customer related information was stored in the users local storage indefintely causing cache mismatches:
24
+
25
+ - 1. It stores a lot less by using the newly created _persistenceMapper_.
26
+ - 2. The 'createCacheReviver' would recreate the ApolloClient-cache on each navigation, it wont do that anymore.
27
+ - 3. The _persistenceMapper_ now has a hard coded blacklist of entries that aren't allowed to be stored in the local storage. In a future PR we'll make this blacklist configurable. ([@paales](https://github.com/paales))
28
+
29
+ ## 6.2.0-canary.98
30
+
31
+ ## 6.2.0-canary.97
32
+
33
+ ## 6.2.0-canary.96
34
+
35
+ ## 6.2.0-canary.95
36
+
37
+ ## 6.2.0-canary.94
38
+
39
+ ## 6.2.0-canary.93
40
+
41
+ ## 6.2.0-canary.92
42
+
43
+ ## 6.2.0-canary.91
44
+
45
+ ## 6.2.0-canary.90
46
+
47
+ ## 6.2.0-canary.89
48
+
49
+ ### Patch Changes
50
+
51
+ - [#2031](https://github.com/graphcommerce-org/graphcommerce/pull/2031) [`4d8fc9e99`](https://github.com/graphcommerce-org/graphcommerce/commit/4d8fc9e998fc9361282833316ec9564da0644ed6) - Eslint fixes and suppress accepted warnings ([@paales](https://github.com/paales))
52
+
53
+ ## 6.2.0-canary.88
54
+
55
+ ## 6.2.0-canary.87
56
+
57
+ ## 6.2.0-canary.86
58
+
59
+ ## 6.2.0-canary.85
60
+
61
+ ## 6.2.0-canary.84
62
+
63
+ ## 6.2.0-canary.83
64
+
65
+ ## 6.2.0-canary.82
66
+
67
+ ## 6.2.0-canary.81
68
+
69
+ ## 6.2.0-canary.80
70
+
71
+ ## 6.2.0-canary.79
72
+
73
+ ## 6.2.0-canary.78
74
+
75
+ ## 6.2.0-canary.77
76
+
77
+ ## 6.2.0-canary.76
78
+
79
+ ## 6.2.0-canary.75
80
+
81
+ ## 6.2.0-canary.74
82
+
83
+ ## 6.2.0-canary.73
84
+
85
+ ## 6.2.0-canary.72
86
+
87
+ ## 6.2.0-canary.71
88
+
89
+ ## 6.2.0-canary.70
90
+
91
+ ## 6.2.0-canary.69
92
+
93
+ ### Patch Changes
94
+
95
+ - [#2012](https://github.com/graphcommerce-org/graphcommerce/pull/2012) [`1dbb3ae13`](https://github.com/graphcommerce-org/graphcommerce/commit/1dbb3ae13553992ee1ed77f375375560f28c418c) - Upgrade graphql to 16.7.1, add graphql as peer dependency ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
96
+
97
+ ## 6.2.0-canary.68
98
+
99
+ ## 6.2.0-canary.67
100
+
101
+ ### Patch Changes
102
+
103
+ - [#2002](https://github.com/graphcommerce-org/graphcommerce/pull/2002) [`1234bb61f`](https://github.com/graphcommerce-org/graphcommerce/commit/1234bb61f8332da8a9e4dd7262b0c70beaed8c91) - Updated next and apollo/client ([@paales](https://github.com/paales))
104
+
105
+ ## 6.2.0-canary.66
106
+
107
+ ## 6.2.0-canary.65
108
+
109
+ ## 6.2.0-canary.64
110
+
111
+ ## 6.2.0-canary.63
112
+
113
+ ## 6.2.0-canary.62
114
+
115
+ ## 6.2.0-canary.61
116
+
117
+ ## 6.2.0-canary.60
118
+
119
+ ## 6.2.0-canary.59
120
+
121
+ ## 6.2.0-canary.58
122
+
123
+ ## 6.2.0-canary.57
124
+
125
+ ## 6.2.0-canary.56
126
+
127
+ ## 6.2.0-canary.55
128
+
129
+ ## 6.2.0-canary.54
130
+
131
+ ## 6.2.0-canary.53
132
+
133
+ ## 6.2.0-canary.52
134
+
135
+ ## 6.2.0-canary.51
136
+
137
+ ## 6.2.0-canary.50
138
+
139
+ ## 6.2.0-canary.49
140
+
141
+ ## 6.2.0-canary.48
142
+
143
+ ## 6.2.0-canary.47
144
+
145
+ ## 6.2.0-canary.46
146
+
147
+ ## 6.2.0-canary.45
148
+
149
+ ## 6.2.0-canary.44
150
+
151
+ ## 6.2.0-canary.43
152
+
153
+ ## 6.2.0-canary.42
154
+
155
+ ## 6.2.0-canary.41
156
+
157
+ ### Patch Changes
158
+
159
+ - [#1960](https://github.com/graphcommerce-org/graphcommerce/pull/1960) [`f78caf5a8`](https://github.com/graphcommerce-org/graphcommerce/commit/f78caf5a83683f1ae4b901fb94bd22d50943fa2f) - Updated packages @apollo/client, react-hook-form, @emotion/\*, @lingui/\*, @mui/\* and various others. ([@paales](https://github.com/paales))
160
+
161
+ - [#1960](https://github.com/graphcommerce-org/graphcommerce/pull/1960) [`86e14569b`](https://github.com/graphcommerce-org/graphcommerce/commit/86e14569b1f68f73be7f93b614e36b382c5debff) - Updated to the latest release of GraphQL codegen and solve compatibility issues with our own generator ([@paales](https://github.com/paales))
162
+
163
+ ## 6.2.0-canary.40
164
+
165
+ ## 6.2.0-canary.39
166
+
167
+ ## 6.2.0-canary.38
168
+
169
+ ## 6.2.0-canary.37
170
+
171
+ ## 6.2.0-canary.36
172
+
173
+ ## 6.2.0-canary.35
174
+
175
+ ## 6.2.0-canary.34
176
+
177
+ ## 6.2.0-canary.33
178
+
179
+ ## 6.2.0-canary.32
180
+
181
+ ## 6.2.0-canary.31
182
+
183
+ ## 6.2.0-canary.30
184
+
185
+ ### Patch Changes
186
+
187
+ - [#1942](https://github.com/graphcommerce-org/graphcommerce/pull/1942) [`df2b3efb2`](https://github.com/graphcommerce-org/graphcommerce/commit/df2b3efb2f906232a302218678c1524753c5a32c) - Customer related information was stored in the users local storage indefintely causing cache mismatches: 1. It stores a lot less by using the newly created _persistenceMapper_. 2. The 'createCacheReviver' would recreate the ApolloClient-cache on each navigation, it wont do that anymore. 3. The _persistenceMapper_ now has a hard coded blacklist of entries that aren't allowed to be stored in the local storage. In a future PR we'll make this blacklist configurable. ([@paales](https://github.com/paales))
188
+
189
+ ## 6.2.0-canary.29
190
+
191
+ ## 6.2.0-canary.28
192
+
193
+ ## 6.2.0-canary.27
194
+
195
+ ## 6.2.0-canary.26
196
+
197
+ ## 6.2.0-canary.25
198
+
199
+ ## 6.2.0-canary.24
200
+
201
+ ## 6.2.0-canary.23
202
+
203
+ ## 6.2.0-canary.22
204
+
205
+ ## 6.2.0-canary.21
4
206
 
5
207
  ## 6.2.0-canary.20
6
208
 
@@ -6,7 +6,8 @@ import {
6
6
  ApolloProvider,
7
7
  HttpLink,
8
8
  } from '@apollo/client'
9
- import { useStorefrontConfig } from '@graphcommerce/next-ui'
9
+ // eslint-disable-next-line import/no-extraneous-dependencies
10
+ import { useStorefrontConfig } from '@graphcommerce/next-ui/hooks/useStorefrontConfig'
10
11
  import type { AppProps } from 'next/app'
11
12
  import { useCallback, useEffect, useRef, useState } from 'react'
12
13
  import { ApolloClientConfig, graphqlConfig, ApolloClientConfigInput } from '../../config'
@@ -2,6 +2,7 @@ import { LocalStorageWrapper, CachePersistor } from 'apollo3-cache-persist'
2
2
  import { mergeDeep, ApolloCache, ApolloClient, NormalizedCacheObject } from '../../apollo'
3
3
  import { ApolloClientConfig } from '../../config'
4
4
  import { migrateCacheHandler } from './migrateCache'
5
+ import { persistenceMapper } from './persistenceMapper'
5
6
  import { getTypePoliciesVersion } from './typePolicies'
6
7
 
7
8
  const APOLLO_CACHE_PERSIST = 'apollo-cache-persist'
@@ -23,24 +24,26 @@ export async function createCacheReviver(
23
24
  try {
24
25
  const { cache } = client
25
26
 
26
- if (persistor) await persistor.persist()
27
- // todo https://github.com/apollographql/apollo-cache-persist/tree/master/examples/react-native/src/utils/persistence
27
+ if (persistor) {
28
+ await persistor.persist()
29
+ return
30
+ }
31
+
28
32
  persistor = new CachePersistor({
29
33
  cache,
30
34
  storage: new LocalStorageWrapper(window.localStorage),
31
35
  maxSize: false,
32
36
  key: APOLLO_CACHE_PERSIST,
37
+ debounce: 10,
38
+ persistenceMapper,
33
39
  })
34
40
 
35
- client.onClearStore(async () => {
36
- client.cache.restore(incomingState)
37
- await persistor?.persist()
38
- })
39
-
40
- client.onResetStore(async () => {
41
+ const reset = async () => {
41
42
  client.cache.restore(incomingState)
42
43
  await persistor?.persist()
43
- })
44
+ }
45
+ client.onClearStore(reset)
46
+ client.onResetStore(reset)
44
47
 
45
48
  const storedState = window.localStorage[APOLLO_CACHE_PERSIST] as string | undefined
46
49
  const currentVersion = window.localStorage[APOLLO_CACHE_VERSION] as string | undefined
@@ -68,14 +71,12 @@ export async function createCacheReviver(
68
71
  }
69
72
  }
70
73
  window.localStorage[APOLLO_CACHE_VERSION] = typePoliciesVersion
71
- window.localStorage[APOLLO_CACHE_PERSIST] = JSON.stringify(state)
72
-
73
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
74
- persistor.restore()
75
74
  } catch (e) {
76
75
  console.error(e)
77
76
  }
78
77
  }
79
78
 
80
- if (state) client.cache.restore(state)
79
+ if (state) {
80
+ client.cache.restore(state)
81
+ }
81
82
  }
@@ -43,7 +43,7 @@ const renderLine = (line: {
43
43
 
44
44
  export const flushMeasurePerf = () => {
45
45
  const entries = Array.from(running.entries())
46
- if (entries.length === 0 || !entries.every(([k, v]) => v.end)) return
46
+ if (entries.length === 0 || !entries.every(([, v]) => v.end)) return
47
47
 
48
48
  /**
49
49
  * Print to the console a timeline that gives a visual reprentation of the starting time and
@@ -55,7 +55,7 @@ export const flushMeasurePerf = () => {
55
55
 
56
56
  let start = Number.MAX_VALUE
57
57
  let end = 0
58
- entries.forEach(([_, value]) => {
58
+ entries.forEach(([, value]) => {
59
59
  if (value.start.getTime() < start) start = value.start.getTime()
60
60
  if (value.end && value.end.getTime() > end) end = value.end.getTime()
61
61
  })
@@ -63,7 +63,7 @@ export const flushMeasurePerf = () => {
63
63
 
64
64
  const colDivider = end > 1000 ? end / 50 : 1000 / 50
65
65
 
66
- const lines = entries.map(([_, value]) => {
66
+ const lines = entries.map(([, value]) => {
67
67
  const requestStart = value.start.getTime() - start
68
68
  const requestEnd = value.end ? value.end.getTime() - start : 0
69
69
  const duration = requestEnd - requestStart
@@ -109,9 +109,10 @@ export const flushMeasurePerf = () => {
109
109
  // padd the items to the max length
110
110
  items.forEach((item) => {
111
111
  item.forEach((_, index) => {
112
- const [str, link] = (
113
- Array.isArray(item[index]) ? item[index] : [item[index], item[index]]
114
- ) as [string, string]
112
+ const [str] = (Array.isArray(item[index]) ? item[index] : [item[index], item[index]]) as [
113
+ string,
114
+ string,
115
+ ]
115
116
 
116
117
  const val = (Array.isArray(item[index]) ? item[index][1] : item[index]) as string
117
118
 
@@ -0,0 +1,43 @@
1
+ import { InMemoryCache, NormalizedCacheObject } from '@apollo/client'
2
+
3
+ function pruneKey(cacheValue: unknown, path: string[]) {
4
+ if (typeof cacheValue !== 'object' || cacheValue === null) return
5
+
6
+ const [segment, ...rest] = path
7
+ const regexp = new RegExp(
8
+ segment.replace(/\*/g, '.*?').replace(/\(/g, '\\(').replace(/\)/g, '\\)').replace(/=/g, '\\='),
9
+ )
10
+
11
+ Object.keys(cacheValue).forEach((key) => {
12
+ if (!regexp.test(key)) return
13
+
14
+ if (rest.length === 0) {
15
+ delete cacheValue[key]
16
+ } else pruneKey(cacheValue[key], rest)
17
+ })
18
+ }
19
+
20
+ function pruneCache(cacheObject: object, patterns: string[]) {
21
+ patterns.forEach((pattern) => pruneKey(cacheObject, pattern.split('.')))
22
+ }
23
+
24
+ export const persistenceMapper = (data: string): Promise<string> => {
25
+ const parsedCache = JSON.parse(data) as NormalizedCacheObject
26
+
27
+ pruneCache(parsedCache, [
28
+ 'ROOT_MUTATION',
29
+ 'ROOT_QUERY.products*',
30
+ 'ROOT_QUERY.countries',
31
+ 'ROOT_QUERY.checkoutAgreements',
32
+ 'ROOT_QUERY.storeConfig',
33
+ 'ROOT_QUERY.__type*',
34
+ 'ConfigurableProduct:*.configurable_product_options_selection*',
35
+ '*Product:{"uid":"*"}.crosssell_products',
36
+ ])
37
+
38
+ const cache = new InMemoryCache({})
39
+ cache.restore(parsedCache)
40
+ cache.gc()
41
+ const newCache = cache.extract()
42
+ return Promise.resolve(JSON.stringify(newCache))
43
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/graphql",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "7.0.0-canary.21",
5
+ "version": "7.0.1-canary.0",
6
6
  "sideEffects": false,
7
7
  "main": "index.ts",
8
8
  "prettier": "@graphcommerce/prettier-config-pwa",
@@ -13,27 +13,27 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "@apollo/client": "^3.7.10",
17
- "@graphcommerce/graphql-codegen-near-operation-file": "7.0.0-canary.21",
18
- "@graphcommerce/graphql-codegen-relay-optimizer-plugin": "7.0.0-canary.21",
19
- "@graphql-codegen/add": "4.0.1",
20
- "@graphql-codegen/fragment-matcher": "4.0.1",
21
- "@graphql-codegen/introspection": "3.0.1",
22
- "@graphql-codegen/schema-ast": "3.0.1",
23
- "@graphql-codegen/typed-document-node": "3.0.2",
24
- "@graphql-codegen/typescript": "3.0.2",
16
+ "@apollo/client": "~3.8.2",
17
+ "@graphcommerce/graphql-codegen-near-operation-file": "7.0.1-canary.0",
18
+ "@graphcommerce/graphql-codegen-relay-optimizer-plugin": "7.0.1-canary.0",
19
+ "@graphql-codegen/add": "5.0.0",
20
+ "@graphql-codegen/fragment-matcher": "5.0.0",
21
+ "@graphql-codegen/introspection": "4.0.0",
22
+ "@graphql-codegen/schema-ast": "4.0.0",
23
+ "@graphql-codegen/typed-document-node": "5.0.1",
24
+ "@graphql-codegen/typescript": "4.0.1",
25
25
  "@graphql-codegen/typescript-apollo-client-helpers": "2.2.6",
26
- "@graphql-codegen/typescript-document-nodes": "3.0.2",
27
- "@graphql-codegen/typescript-operations": "3.0.2",
28
- "apollo3-cache-persist": "^0.14.1",
29
- "graphql": "16.6.0"
26
+ "@graphql-codegen/typescript-document-nodes": "4.0.1",
27
+ "@graphql-codegen/typescript-operations": "4.0.1",
28
+ "apollo3-cache-persist": "^0.14.1"
30
29
  },
31
30
  "devDependencies": {
32
- "@graphcommerce/eslint-config-pwa": "7.0.0-canary.21",
33
- "@graphcommerce/prettier-config-pwa": "7.0.0-canary.21",
34
- "@graphcommerce/typescript-config-pwa": "7.0.0-canary.21"
31
+ "@graphcommerce/eslint-config-pwa": "7.0.1-canary.0",
32
+ "@graphcommerce/prettier-config-pwa": "7.0.1-canary.0",
33
+ "@graphcommerce/typescript-config-pwa": "7.0.1-canary.0"
35
34
  },
36
35
  "peerDependencies": {
36
+ "graphql": "^16.7.1",
37
37
  "react": "^18.2.0",
38
38
  "react-dom": "^18.2.0"
39
39
  }
@@ -1,3 +1,4 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
1
2
  /* eslint-disable no-empty-pattern */
2
3
  import { test as base, Page } from '@playwright/test'
3
4
  import {