@graphcommerce/graphql 3.0.5 → 3.0.6

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,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1368](https://github.com/graphcommerce-org/graphcommerce/pull/1368) [`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a) Thanks [@paales](https://github.com/paales)! - playwright waitForGraphQlResponse shouldn’t crash on non-graphql responses
8
+
9
+ * [#1369](https://github.com/graphcommerce-org/graphcommerce/pull/1369) [`ae6449502`](https://github.com/graphcommerce-org/graphcommerce/commit/ae64495024a455bbe5188588604368c1542840c9) Thanks [@paales](https://github.com/paales)! - Upgraded dependencies
10
+
11
+ - [#1368](https://github.com/graphcommerce-org/graphcommerce/pull/1368) [`892018809`](https://github.com/graphcommerce-org/graphcommerce/commit/8920188093d0422ec50580e408dc28ac5f93e46a) Thanks [@paales](https://github.com/paales)! - Do not recreate client cache when initialized once, fixes issue where the localStorage wasn't updated yet when a new page is loaded.
12
+
13
+ - Updated dependencies [[`ae6449502`](https://github.com/graphcommerce-org/graphcommerce/commit/ae64495024a455bbe5188588604368c1542840c9)]:
14
+ - @graphcommerce/graphql-codegen-near-operation-file@3.0.9
15
+ - @graphcommerce/graphql-codegen-relay-optimizer-plugin@3.0.6
16
+
3
17
  ## 3.0.5
4
18
 
5
19
  ### Patch Changes
@@ -7,6 +7,10 @@ import { getTypePoliciesVersion } from './typePolicies'
7
7
  const APOLLO_CACHE_PERSIST = 'apollo-cache-persist'
8
8
  const APOLLO_CACHE_VERSION = 'apollo-cache-version'
9
9
 
10
+ let persistor: CachePersistor<NormalizedCacheObject> | undefined
11
+
12
+ export const persistCache = () => persistor?.persist()
13
+
10
14
  /** Revives the cache from the localStorage if it is available. */
11
15
  export function createCacheReviver(
12
16
  client: ApolloClient<NormalizedCacheObject>,
@@ -18,10 +22,12 @@ export function createCacheReviver(
18
22
  let state = incommingState
19
23
  const typePoliciesVersion = getTypePoliciesVersion(policies)
20
24
 
25
+ if (persistor) return
26
+
21
27
  if (typeof window !== 'undefined') {
22
28
  try {
23
29
  const { cache } = client
24
- const persistor = new CachePersistor({
30
+ persistor = new CachePersistor({
25
31
  cache,
26
32
  storage: new LocalStorageWrapper(window.localStorage),
27
33
  maxSize: false,
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": "3.0.5",
5
+ "version": "3.0.6",
6
6
  "sideEffects": false,
7
7
  "main": "index.ts",
8
8
  "prettier": "@graphcommerce/prettier-config-pwa",
@@ -13,15 +13,15 @@
13
13
  }
14
14
  },
15
15
  "devDependencies": {
16
- "@graphcommerce/eslint-config-pwa": "^4.1.1",
17
- "@graphcommerce/prettier-config-pwa": "^4.0.3",
16
+ "@graphcommerce/eslint-config-pwa": "^4.1.3",
17
+ "@graphcommerce/prettier-config-pwa": "^4.0.5",
18
18
  "@graphcommerce/typescript-config-pwa": "^4.0.2",
19
- "@playwright/test": "^1.19.2"
19
+ "@playwright/test": "^1.20.1"
20
20
  },
21
21
  "dependencies": {
22
22
  "@apollo/client": "^3.5.10",
23
- "@graphcommerce/graphql-codegen-near-operation-file": "^3.0.7",
24
- "@graphcommerce/graphql-codegen-relay-optimizer-plugin": "^3.0.5",
23
+ "@graphcommerce/graphql-codegen-near-operation-file": "^3.0.9",
24
+ "@graphcommerce/graphql-codegen-relay-optimizer-plugin": "^3.0.6",
25
25
  "@graphql-codegen/add": "3.1.1",
26
26
  "@graphql-codegen/fragment-matcher": "3.2.1",
27
27
  "@graphql-codegen/introspection": "2.1.1",
@@ -18,9 +18,15 @@ export async function waitForGraphQlResponse<Q, V>(
18
18
  docOrName: string | TypedDocumentNode<Q, V>,
19
19
  ): Promise<FetchResult<Q>> {
20
20
  const name = typeof docOrName === 'string' ? docOrName : getOperationName(docOrName)
21
- const response = await page.waitForResponse(
22
- (r) => r.request().postDataJSON()?.operationName === name,
23
- )
21
+
22
+ const response = await page.waitForResponse((r) => {
23
+ try {
24
+ return r.request().postDataJSON()?.operationName === name
25
+ } catch (e) {
26
+ return false
27
+ }
28
+ })
29
+
24
30
  return (await response?.json()) as FetchResult<Q>
25
31
  }
26
32