@graphcommerce/graphql 2.105.13 → 3.0.2

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,85 +1,121 @@
1
1
  # Change Log
2
2
 
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
3
+ ## 3.0.2
5
4
 
6
- ## [2.105.12](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql@2.105.11...@graphcommerce/graphql@2.105.12) (2021-12-21)
5
+ ### Patch Changes
7
6
 
7
+ - [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
8
+ [`ce09388e0`](https://github.com/ho-nl/m2-pwa/commit/ce09388e0d7ef33aee660612340f6fbae15ceec2)
9
+ Thanks [@paales](https://github.com/paales)! - We've moved lots of internal packages from
10
+ `dependencies` to `peerDependencies`. The result of this is that there will be significantly less
11
+ duplicate packages in the node_modules folders.
8
12
 
9
- ### Bug Fixes
13
+ * [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
14
+ [`52a45bba4`](https://github.com/ho-nl/m2-pwa/commit/52a45bba4dc6dd6df3c81f5023df7d23ed8a534d)
15
+ Thanks [@paales](https://github.com/paales)! - Upgraded to
16
+ [NextJS 12.1](https://nextjs.org/blog/next-12-1)! This is just for compatibility, but we'll be
17
+ implementing
18
+ [On-demand Incremental Static Regeneration](https://nextjs.org/blog/next-12-1#on-demand-incremental-static-regeneration-beta)
19
+ soon.
10
20
 
11
- * **graphql:** make sure we're passing the correct store code to the schema endpoint ([39753f2](https://github.com/ho-nl/m2-pwa/commit/39753f2117ce7ba79dab035c4134e642829e7f18))
21
+ This will greatly reduce the requirement to rebuid stuff and we'll add a management UI on the
22
+ frontend to be able to revalidate pages manually.
12
23
 
24
+ * Updated dependencies
25
+ [[`ce09388e0`](https://github.com/ho-nl/m2-pwa/commit/ce09388e0d7ef33aee660612340f6fbae15ceec2),
26
+ [`52a45bba4`](https://github.com/ho-nl/m2-pwa/commit/52a45bba4dc6dd6df3c81f5023df7d23ed8a534d)]:
27
+ - @graphcommerce/graphql-codegen-near-operation-file@3.0.2
28
+ - @graphcommerce/graphql-codegen-relay-optimizer-plugin@3.0.2
13
29
 
30
+ ## 3.0.1
14
31
 
32
+ ### Patch Changes
15
33
 
34
+ - [`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)
35
+ Thanks [@paales](https://github.com/paales)! - Added homepage and repository package.json files,
36
+ so that the packages link to back to the website and repository
37
+ - Updated dependencies
38
+ [[`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)]:
39
+ - @graphcommerce/graphql-codegen-near-operation-file@3.0.1
40
+ - @graphcommerce/graphql-codegen-relay-optimizer-plugin@3.0.1
16
41
 
17
- ## [2.105.6](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql@2.105.5...@graphcommerce/graphql@2.105.6) (2021-12-03)
42
+ ## 3.0.0
18
43
 
44
+ ### Major Changes
19
45
 
20
- ### Bug Fixes
21
-
22
- * make the headerHeight properly configurable ([c39c942](https://github.com/ho-nl/m2-pwa/commit/c39c942a62a9bb9687ea553be28e37fb49a6b065))
46
+ - [#1258](https://github.com/ho-nl/m2-pwa/pull/1258)
47
+ [`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05)
48
+ Thanks [@paales](https://github.com/paales)! - Upgraded to Material UI 5
23
49
 
50
+ ### Patch Changes
24
51
 
52
+ - Updated dependencies
53
+ [[`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05)]:
54
+ - @graphcommerce/graphql-codegen-near-operation-file@3.0.0
55
+ - @graphcommerce/graphql-codegen-relay-optimizer-plugin@3.0.0
25
56
 
57
+ All notable changes to this project will be documented in this file. See
58
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
26
59
 
60
+ ## [2.105.12](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql@2.105.11...@graphcommerce/graphql@2.105.12) (2021-12-21)
27
61
 
28
- # [2.105.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql@2.104.1...@graphcommerce/graphql@2.105.0) (2021-10-27)
62
+ ### Bug Fixes
29
63
 
64
+ - **graphql:** make sure we're passing the correct store code to the schema endpoint
65
+ ([39753f2](https://github.com/ho-nl/m2-pwa/commit/39753f2117ce7ba79dab035c4134e642829e7f18))
30
66
 
31
- ### Features
67
+ ## [2.105.6](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql@2.105.5...@graphcommerce/graphql@2.105.6) (2021-12-03)
32
68
 
33
- * **nextjs:** upgraded to nextjs 12 ([9331bc8](https://github.com/ho-nl/m2-pwa/commit/9331bc801f6419522115cc47d291d49d608d5a90))
69
+ ### Bug Fixes
34
70
 
71
+ - make the headerHeight properly configurable
72
+ ([c39c942](https://github.com/ho-nl/m2-pwa/commit/c39c942a62a9bb9687ea553be28e37fb49a6b065))
35
73
 
74
+ # [2.105.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql@2.104.1...@graphcommerce/graphql@2.105.0) (2021-10-27)
36
75
 
76
+ ### Features
37
77
 
78
+ - **nextjs:** upgraded to nextjs 12
79
+ ([9331bc8](https://github.com/ho-nl/m2-pwa/commit/9331bc801f6419522115cc47d291d49d608d5a90))
38
80
 
39
81
  # [2.104.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql@2.103.8...@graphcommerce/graphql@2.104.0) (2021-10-21)
40
82
 
41
-
42
83
  ### Features
43
84
 
44
- * **graphql-mesh:** remove the api project and use a single project 🎉👩‍👩‍👦‍👦 ([ea4ad03](https://github.com/ho-nl/m2-pwa/commit/ea4ad0397d4ff289ef3b3253593fb0914c8c5246))
45
-
46
-
47
-
48
-
85
+ - **graphql-mesh:** remove the api project and use a single project 🎉👩‍👩‍👦‍👦
86
+ ([ea4ad03](https://github.com/ho-nl/m2-pwa/commit/ea4ad0397d4ff289ef3b3253593fb0914c8c5246))
49
87
 
50
88
  ## [2.103.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql@2.103.0...@graphcommerce/graphql@2.103.1) (2021-09-27)
51
89
 
52
90
  **Note:** Version bump only for package @graphcommerce/graphql
53
91
 
54
-
55
-
56
-
57
-
58
92
  # 2.103.0 (2021-09-27)
59
93
 
60
-
61
94
  ### Bug Fixes
62
95
 
63
- * ignore md files from triggering version updates ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
64
-
96
+ - ignore md files from triggering version updates
97
+ ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
65
98
 
66
99
  ### Features
67
100
 
68
- * **graphql:** introduced new graphql package that holds all generated files ([a3e7aa0](https://github.com/ho-nl/m2-pwa/commit/a3e7aa05540540533b5ced9a95f1f802ecbe499f))
69
- * **graphql:** introducing local schema migrations ([e77ef8a](https://github.com/ho-nl/m2-pwa/commit/e77ef8ad4cd5723e2352dec937b45ee976929b24))
70
- * next.js 11 ([7d61407](https://github.com/ho-nl/m2-pwa/commit/7d614075a778f488045034f74be4f75b93f63c43))
71
- * **playwright:** added new playwright package to enable browser testing ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
72
- * renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of [@reachdigital](https://github.com/reachdigital) ([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
73
- * upgraded to nextjs 11 ([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
74
-
101
+ - **graphql:** introduced new graphql package that holds all generated files
102
+ ([a3e7aa0](https://github.com/ho-nl/m2-pwa/commit/a3e7aa05540540533b5ced9a95f1f802ecbe499f))
103
+ - **graphql:** introducing local schema migrations
104
+ ([e77ef8a](https://github.com/ho-nl/m2-pwa/commit/e77ef8ad4cd5723e2352dec937b45ee976929b24))
105
+ - next.js 11
106
+ ([7d61407](https://github.com/ho-nl/m2-pwa/commit/7d614075a778f488045034f74be4f75b93f63c43))
107
+ - **playwright:** added new playwright package to enable browser testing
108
+ ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
109
+ - renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of
110
+ [@reachdigital](https://github.com/reachdigital)
111
+ ([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
112
+ - upgraded to nextjs 11
113
+ ([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
75
114
 
76
115
  ### Reverts
77
116
 
78
- * Revert "chore: upgrade @apollo/client" ([55ff24e](https://github.com/ho-nl/m2-pwa/commit/55ff24ede0e56c85b8095edadadd1ec5e0b1b8d2))
79
-
80
-
81
-
82
-
117
+ - Revert "chore: upgrade @apollo/client"
118
+ ([55ff24e](https://github.com/ho-nl/m2-pwa/commit/55ff24ede0e56c85b8095edadadd1ec5e0b1b8d2))
83
119
 
84
120
  # Change Log
85
121
 
@@ -1,13 +1,13 @@
1
1
  /* eslint-disable no-empty-pattern */
2
+ import { getOperationName } from '@graphcommerce/graphql'
3
+ import { test as base, Page } from '@playwright/test'
2
4
  import {
3
5
  ApolloClient,
4
6
  FetchResult,
5
7
  InMemoryCache,
6
8
  NormalizedCacheObject,
7
9
  TypedDocumentNode,
8
- } from '@apollo/client'
9
- import { getOperationName } from '@apollo/client/utilities'
10
- import { test as base, Page } from '@playwright/test'
10
+ } from '../apollo'
11
11
 
12
12
  type ApolloClientTest = {
13
13
  apolloClient: ApolloClient<NormalizedCacheObject>
package/apollo.ts ADDED
@@ -0,0 +1,6 @@
1
+ export { cloneDeep, mergeDeep } from '@apollo/client/utilities'
2
+
3
+ export * from '@apollo/client'
4
+ export * from '@apollo/client/link/schema'
5
+ export * from '@apollo/client/link/context'
6
+ export { getOperationName } from '@apollo/client/utilities'
@@ -0,0 +1,67 @@
1
+ import { LocalStorageWrapper, CachePersistor } from 'apollo3-cache-persist'
2
+ import { mergeDeep, ApolloCache, ApolloClient, NormalizedCacheObject } from './apollo'
3
+ import type { TypedTypePolicies } from './generated/types'
4
+ import { MigrateCache, migrateCacheHandler } from './migrateCache'
5
+ import { getTypePoliciesVersion } from './typePolicies'
6
+
7
+ const APOLLO_CACHE_PERSIST = 'apollo-cache-persist'
8
+ const APOLLO_CACHE_VERSION = 'apollo-cache-version'
9
+
10
+ /** Revives the cache from the localStorage if it is available. */
11
+ export function createCacheReviver(
12
+ client: ApolloClient<NormalizedCacheObject>,
13
+ createCache: () => ApolloCache<NormalizedCacheObject>,
14
+ policies: TypedTypePolicies[],
15
+ migrations: MigrateCache[],
16
+ incommingState: NormalizedCacheObject = {},
17
+ ) {
18
+ let state = incommingState
19
+ const typePoliciesVersion = getTypePoliciesVersion(policies)
20
+
21
+ if (typeof window !== 'undefined') {
22
+ try {
23
+ const { cache } = client
24
+ const persistor = new CachePersistor({
25
+ cache,
26
+ storage: new LocalStorageWrapper(window.localStorage),
27
+ maxSize: false,
28
+ key: APOLLO_CACHE_PERSIST,
29
+ })
30
+
31
+ const storedState = window.localStorage[APOLLO_CACHE_PERSIST] as string | undefined
32
+ const currentVersion = window.localStorage[APOLLO_CACHE_VERSION] as string | undefined
33
+
34
+ if (currentVersion === typePoliciesVersion && storedState) {
35
+ state = mergeDeep(JSON.parse(storedState), incommingState)
36
+ } else if (storedState) {
37
+ console.info(
38
+ '[@graphcommerce/graphql] migrating apollo cache, detected a typePolicy change',
39
+ )
40
+ try {
41
+ const oldCache = createCache()
42
+ oldCache.restore(JSON.parse(storedState) as NormalizedCacheObject)
43
+
44
+ // Run the migration
45
+ migrateCacheHandler(oldCache, cache, migrations)
46
+
47
+ state = mergeDeep(cache.extract(), incommingState)
48
+ console.info('migration complete')
49
+ } catch (e) {
50
+ console.info('migration error (starting with a clean state):', e)
51
+
52
+ // couldn't be upgraded
53
+ state = incommingState
54
+ }
55
+ }
56
+ window.localStorage[APOLLO_CACHE_VERSION] = typePoliciesVersion
57
+ window.localStorage[APOLLO_CACHE_PERSIST] = JSON.stringify(state)
58
+
59
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
60
+ persistor.restore()
61
+ } catch (e) {
62
+ console.error(e)
63
+ }
64
+ }
65
+
66
+ if (state) client.cache.restore(state)
67
+ }
package/index.ts CHANGED
@@ -1,8 +1,13 @@
1
+ export * from './generated/types'
2
+
1
3
  export * from './measurePerformanceLink'
2
4
  export * from './errorLink'
3
5
 
4
- export * from './generated/types'
5
6
  export { default as fragments } from './generated/fragments.json'
6
7
 
7
8
  export * from './migrateCache'
8
9
  export * from './typePolicies'
10
+ export * from './createCacheReviver'
11
+
12
+ export * from './apollo'
13
+ export * from './types'
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-console */
2
- import { ApolloLink } from '@apollo/client/core'
2
+ import { ApolloLink } from '@apollo/client'
3
3
 
4
4
  const slowOperationThreshold = 1000
5
5
  const slowResolverThreshold = 300
package/migrateCache.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ApolloCache, NormalizedCacheObject } from '@apollo/client'
1
+ import { ApolloCache, NormalizedCacheObject } from './apollo'
2
2
 
3
3
  export type MigrateCache = (
4
4
  oldCache: ApolloCache<NormalizedCacheObject>,
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@graphcommerce/graphql",
3
- "version": "2.105.13",
3
+ "homepage": "https://www.graphcommerce.org/",
4
+ "repository": "github:graphcommerce-org/graphcommerce",
5
+ "version": "3.0.2",
4
6
  "sideEffects": false,
5
7
  "main": "index.ts",
6
8
  "prettier": "@graphcommerce/prettier-config-pwa",
7
- "browserslist": [
8
- "extends @graphcommerce/browserslist-config-pwa"
9
- ],
10
9
  "eslintConfig": {
11
10
  "extends": "@graphcommerce/eslint-config-pwa",
12
11
  "parserOptions": {
@@ -14,26 +13,25 @@
14
13
  }
15
14
  },
16
15
  "devDependencies": {
17
- "@graphcommerce/browserslist-config-pwa": "^3.0.3",
18
- "@graphcommerce/eslint-config-pwa": "^3.1.10",
19
- "@graphcommerce/prettier-config-pwa": "^3.0.5",
20
- "@graphcommerce/typescript-config-pwa": "^3.1.2",
21
- "@playwright/test": "^1.17.1"
16
+ "@graphcommerce/eslint-config-pwa": "^4.0.2",
17
+ "@graphcommerce/prettier-config-pwa": "^4.0.1",
18
+ "@graphcommerce/typescript-config-pwa": "^4.0.1",
19
+ "@playwright/test": "^1.19.1"
22
20
  },
23
21
  "dependencies": {
24
- "@apollo/client": "^3.5.6",
25
- "@graphcommerce/graphql-codegen-near-operation-file": "^2.103.19",
26
- "@graphcommerce/graphql-codegen-relay-optimizer-plugin": "^2.102.20",
22
+ "@apollo/client": "^3.5.9",
23
+ "@graphcommerce/graphql-codegen-near-operation-file": "^3.0.2",
24
+ "@graphcommerce/graphql-codegen-relay-optimizer-plugin": "^3.0.2",
27
25
  "@graphql-codegen/add": "^3.1.1",
28
26
  "@graphql-codegen/fragment-matcher": "3.2.1",
29
27
  "@graphql-codegen/introspection": "2.1.1",
30
28
  "@graphql-codegen/schema-ast": "^2.4.1",
31
- "@graphql-codegen/typed-document-node": "^2.2.2",
32
- "@graphql-codegen/typescript": "^2.4.2",
33
- "@graphql-codegen/typescript-apollo-client-helpers": "^2.1.9",
34
- "@graphql-codegen/typescript-document-nodes": "2.2.2",
35
- "@graphql-codegen/typescript-operations": "2.2.2",
36
- "graphql": "^16.2.0"
37
- },
38
- "gitHead": "bc5423d7547f8685db4cd8fc6d8f7a2a51ebed05"
29
+ "@graphql-codegen/typed-document-node": "^2.2.5",
30
+ "@graphql-codegen/typescript": "^2.4.5",
31
+ "@graphql-codegen/typescript-apollo-client-helpers": "^2.1.12",
32
+ "@graphql-codegen/typescript-document-nodes": "2.2.5",
33
+ "@graphql-codegen/typescript-operations": "2.3.2",
34
+ "apollo3-cache-persist": "^0.14.0",
35
+ "graphql": "^16.3.0"
36
+ }
39
37
  }
package/typePolicies.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { mergeDeep } from '@apollo/client/utilities'
2
- import { TypedTypePolicies } from './generated/types'
1
+ import { mergeDeep } from './apollo'
2
+ import type { TypedTypePolicies } from './generated/types'
3
3
 
4
4
  export const mergeTypePolicies = (policies: TypedTypePolicies[]): TypedTypePolicies =>
5
5
  mergeDeep(...policies)
package/types.ts ADDED
@@ -0,0 +1,16 @@
1
+ /** The GraphQL API will return fields as null if they are not required. */
2
+ export type ObjectNonNullable<T> = {
3
+ [P in keyof T]: NonNullable<T[P]>
4
+ }
5
+
6
+ /** Typescript will return null for fields */
7
+ export function removeNull<T extends Record<string, unknown>>(object: T): ObjectNonNullable<T> {
8
+ // eslint-disable-next-line no-restricted-syntax
9
+
10
+ const myobj = { ...object } as ObjectNonNullable<T>
11
+ Object.keys(myobj).forEach((key: keyof T) => {
12
+ if (myobj[key] === null) myobj[key] = undefined as NonNullable<T[keyof T]>
13
+ })
14
+
15
+ return myobj
16
+ }