@graphcommerce/graphql 9.1.0-canary.34 → 9.1.0-canary.35
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 +8 -0
- package/components/GraphQLProvider/GraphQLProvider.tsx +2 -1
- package/components/GraphQLProvider/createCacheReviver.ts +2 -2
- package/components/GraphQLProvider/persistenceMapper.ts +29 -28
- package/components/GraphQLProvider/typePolicies.ts +3 -0
- package/hooks/usePrivateQueryContext.ts +0 -2
- package/package.json +6 -6
- /package/schema/{InContext.graphqls → PrivateContext.graphqls} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.1.0-canary.35
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2528](https://github.com/graphcommerce-org/graphcommerce/pull/2528) [`c52604f`](https://github.com/graphcommerce-org/graphcommerce/commit/c52604f89e1776fc1f0913f016b8b24fa194c6b7) - Solve issue where the persistenceMapper didn't use the same typePolicies and other configuration from the cache, causing potential issues. ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
9
|
+
- [#2528](https://github.com/graphcommerce-org/graphcommerce/pull/2528) [`529d7a8`](https://github.com/graphcommerce-org/graphcommerce/commit/529d7a88a4e010cb3e50c1358e2ac43e80e0bf38) - Solve issue where the ApolloClient cache wasn't scoped properly causing the wrong currency to be shown when switching currency. ([@paales](https://github.com/paales))
|
|
10
|
+
|
|
3
11
|
## 9.1.0-canary.34
|
|
4
12
|
|
|
5
13
|
## 9.1.0-canary.33
|
|
@@ -10,7 +10,7 @@ import fragments from '../../generated/fragments.json'
|
|
|
10
10
|
import { createCacheReviver } from './createCacheReviver'
|
|
11
11
|
import { errorLink } from './errorLink'
|
|
12
12
|
import { measurePerformanceLink } from './measurePerformanceLink'
|
|
13
|
-
import { mergeTypePolicies } from './typePolicies'
|
|
13
|
+
import { dataIdFromObject, mergeTypePolicies } from './typePolicies'
|
|
14
14
|
|
|
15
15
|
export const globalApolloClient: { current: ApolloClient<NormalizedCacheObject> | null } = {
|
|
16
16
|
current: null,
|
|
@@ -47,6 +47,7 @@ export function GraphQLProvider(props: GraphQLProviderProps) {
|
|
|
47
47
|
new InMemoryCache({
|
|
48
48
|
possibleTypes: fragments.possibleTypes,
|
|
49
49
|
typePolicies: mergeTypePolicies(config.current.policies),
|
|
50
|
+
dataIdFromObject,
|
|
50
51
|
}),
|
|
51
52
|
[],
|
|
52
53
|
)
|
|
@@ -3,7 +3,7 @@ import type { ApolloCache, ApolloClient, NormalizedCacheObject } from '../../apo
|
|
|
3
3
|
import { mergeDeep } from '../../apollo'
|
|
4
4
|
import type { ApolloClientConfig } from '../../config'
|
|
5
5
|
import { migrateCacheHandler } from './migrateCache'
|
|
6
|
-
import {
|
|
6
|
+
import { createPersistenceMapper } from './persistenceMapper'
|
|
7
7
|
import { getTypePoliciesVersion } from './typePolicies'
|
|
8
8
|
|
|
9
9
|
const APOLLO_CACHE_PERSIST = 'apollo-cache-persist'
|
|
@@ -36,7 +36,7 @@ export async function createCacheReviver(
|
|
|
36
36
|
maxSize: false,
|
|
37
37
|
key: APOLLO_CACHE_PERSIST,
|
|
38
38
|
debounce: 10,
|
|
39
|
-
persistenceMapper,
|
|
39
|
+
persistenceMapper: createPersistenceMapper(createCache),
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
const reset = async () => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { NormalizedCacheObject } from '@apollo/client'
|
|
2
|
-
import { InMemoryCache } from '@apollo/client'
|
|
1
|
+
import type { ApolloCache, NormalizedCacheObject } from '@apollo/client'
|
|
3
2
|
|
|
4
3
|
function pruneKey(cacheValue: unknown, path: string[]) {
|
|
5
4
|
if (typeof cacheValue !== 'object' || cacheValue === null) return
|
|
@@ -22,29 +21,31 @@ function pruneCache(cacheObject: object, patterns: string[]) {
|
|
|
22
21
|
patterns.forEach((pattern) => pruneKey(cacheObject, pattern.split('.')))
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
export const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
24
|
+
export const createPersistenceMapper =
|
|
25
|
+
(createCache: () => ApolloCache<NormalizedCacheObject>) =>
|
|
26
|
+
(data: string): Promise<string> => {
|
|
27
|
+
const parsedCache = JSON.parse(data) as NormalizedCacheObject
|
|
28
|
+
|
|
29
|
+
pruneCache(parsedCache, [
|
|
30
|
+
'ROOT_MUTATION',
|
|
31
|
+
'ROOT_QUERY.attributesForm',
|
|
32
|
+
'ROOT_QUERY.attributesList',
|
|
33
|
+
'ROOT_QUERY.categories*',
|
|
34
|
+
'ROOT_QUERY.products*',
|
|
35
|
+
'ROOT_QUERY.countries',
|
|
36
|
+
'ROOT_QUERY.checkoutAgreements',
|
|
37
|
+
'ROOT_QUERY.storeConfig',
|
|
38
|
+
'ROOT_QUERY.currency',
|
|
39
|
+
'ROOT_QUERY.guestOrder',
|
|
40
|
+
'ROOT_QUERY.cmsBlocks',
|
|
41
|
+
'ROOT_QUERY.__type*',
|
|
42
|
+
'*Product:{"uid":"*"}.crosssell_products',
|
|
43
|
+
'ROOT_QUERY.recaptchaV3Config',
|
|
44
|
+
])
|
|
45
|
+
|
|
46
|
+
const cache = createCache()
|
|
47
|
+
cache.restore(parsedCache)
|
|
48
|
+
cache.gc()
|
|
49
|
+
const newCache = cache.extract()
|
|
50
|
+
return Promise.resolve(JSON.stringify(newCache))
|
|
51
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StrictTypedTypePolicies } from '@graphcommerce/graphql'
|
|
2
|
+
import type { KeyFieldsFunction } from '@apollo/client/cache/inmemory/policies'
|
|
2
3
|
import { mergeDeep } from '../../apollo'
|
|
3
4
|
|
|
4
5
|
export const mergeTypePolicies = (policies: StrictTypedTypePolicies[]): StrictTypedTypePolicies =>
|
|
@@ -16,3 +17,5 @@ const generateIdentifyer = (s: string) =>
|
|
|
16
17
|
|
|
17
18
|
export const getTypePoliciesVersion = (policies: StrictTypedTypePolicies[]) =>
|
|
18
19
|
generateIdentifyer(JSON.stringify(policies))
|
|
20
|
+
|
|
21
|
+
export const dataIdFromObject: KeyFieldsFunction = () => undefined
|
|
@@ -14,8 +14,6 @@ export function getPrivateQueryContext(
|
|
|
14
14
|
* Other plugins should be able to define their own scopes and create a plugin on this method to
|
|
15
15
|
* augment the specific scope.
|
|
16
16
|
*
|
|
17
|
-
* @see @graphcommerce/magento-customer/plugins/magentoCustomerGetInContext.ts
|
|
18
|
-
*
|
|
19
17
|
* Note: ONLY return a value if the frontend should use the privateContext directive.
|
|
20
18
|
*/
|
|
21
19
|
export const usePrivateQueryContext = (): PrivateContext | null => null
|
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": "9.1.0-canary.
|
|
5
|
+
"version": "9.1.0-canary.35",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "index.ts",
|
|
8
8
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"graphql": "^16.10.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.
|
|
31
|
-
"@graphcommerce/graphql-codegen-near-operation-file": "9.1.0-canary.
|
|
32
|
-
"@graphcommerce/graphql-codegen-relay-optimizer-plugin": "9.1.0-canary.
|
|
33
|
-
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.
|
|
34
|
-
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.
|
|
30
|
+
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.35",
|
|
31
|
+
"@graphcommerce/graphql-codegen-near-operation-file": "9.1.0-canary.35",
|
|
32
|
+
"@graphcommerce/graphql-codegen-relay-optimizer-plugin": "9.1.0-canary.35",
|
|
33
|
+
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.35",
|
|
34
|
+
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.35",
|
|
35
35
|
"@graphql-mesh/plugin-http-details-extensions": "*",
|
|
36
36
|
"react": "^18.2.0",
|
|
37
37
|
"react-dom": "^18.2.0"
|
|
File without changes
|