@graphcommerce/magento-customer 8.0.0 → 8.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,5 +1,15 @@
1
1
  # Change Log
2
2
 
3
+ ## 8.0.1-canary.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2187](https://github.com/graphcommerce-org/graphcommerce/pull/2187) [`09a2cc3`](https://github.com/graphcommerce-org/graphcommerce/commit/09a2cc35ceb5e714ffd02e573eebe7de842ae327) - Do not try to automatically invalidate the current token and fully rely on the Session Expired dialog
8
+ ([@paales](https://github.com/paales))
9
+
10
+ - [#2187](https://github.com/graphcommerce-org/graphcommerce/pull/2187) [`ee969bf`](https://github.com/graphcommerce-org/graphcommerce/commit/ee969bfc5415392747b04e0484685f5c611a2559) - After signing out the currentCartId was still returning a value causing the cart to be shown after signing out
11
+ ([@paales](https://github.com/paales))
12
+
3
13
  ## 8.0.0
4
14
 
5
15
  ### Minor Changes
@@ -1,9 +1,10 @@
1
1
  import { ApolloClient } from '@graphcommerce/graphql'
2
2
 
3
3
  export function signOut(client: ApolloClient<object>) {
4
- client.cache.evict({ fieldName: 'currentCartId', broadcast: true })
5
- client.cache.evict({ fieldName: 'cart', broadcast: true })
6
- client.cache.evict({ fieldName: 'customerToken', broadcast: true })
7
- client.cache.evict({ fieldName: 'customer', broadcast: true })
8
- client.cache.evict({ fieldName: 'customerCart', broadcast: true })
4
+ client.cache.evict({ fieldName: 'currentCartId' })
5
+ client.cache.evict({ fieldName: 'cart' })
6
+ client.cache.evict({ fieldName: 'customerToken' })
7
+ client.cache.evict({ fieldName: 'customer' })
8
+ client.cache.evict({ fieldName: 'customerCart' })
9
+ client.cache.gc()
9
10
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-customer",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "8.0.0",
5
+ "version": "8.0.1-canary.0",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,19 +12,19 @@
12
12
  }
13
13
  },
14
14
  "peerDependencies": {
15
- "@graphcommerce/ecommerce-ui": "^8.0.0",
16
- "@graphcommerce/eslint-config-pwa": "^8.0.0",
17
- "@graphcommerce/framer-next-pages": "^8.0.0",
18
- "@graphcommerce/framer-utils": "^8.0.0",
19
- "@graphcommerce/graphql": "^8.0.0",
20
- "@graphcommerce/graphql-mesh": "^8.0.0",
21
- "@graphcommerce/image": "^8.0.0",
22
- "@graphcommerce/magento-graphql": "^8.0.0",
23
- "@graphcommerce/magento-store": "^8.0.0",
24
- "@graphcommerce/next-ui": "^8.0.0",
25
- "@graphcommerce/prettier-config-pwa": "^8.0.0",
26
- "@graphcommerce/react-hook-form": "^8.0.0",
27
- "@graphcommerce/typescript-config-pwa": "^8.0.0",
15
+ "@graphcommerce/ecommerce-ui": "^8.0.1-canary.0",
16
+ "@graphcommerce/eslint-config-pwa": "^8.0.1-canary.0",
17
+ "@graphcommerce/framer-next-pages": "^8.0.1-canary.0",
18
+ "@graphcommerce/framer-utils": "^8.0.1-canary.0",
19
+ "@graphcommerce/graphql": "^8.0.1-canary.0",
20
+ "@graphcommerce/graphql-mesh": "^8.0.1-canary.0",
21
+ "@graphcommerce/image": "^8.0.1-canary.0",
22
+ "@graphcommerce/magento-graphql": "^8.0.1-canary.0",
23
+ "@graphcommerce/magento-store": "^8.0.1-canary.0",
24
+ "@graphcommerce/next-ui": "^8.0.1-canary.0",
25
+ "@graphcommerce/prettier-config-pwa": "^8.0.1-canary.0",
26
+ "@graphcommerce/react-hook-form": "^8.0.1-canary.0",
27
+ "@graphcommerce/typescript-config-pwa": "^8.0.1-canary.0",
28
28
  "@lingui/core": "^4.2.1",
29
29
  "@lingui/macro": "^4.2.1",
30
30
  "@lingui/react": "^4.2.1",
package/typePolicies.ts CHANGED
@@ -1,53 +1,31 @@
1
1
  import type { FieldPolicy, MigrateCache, StrictTypedTypePolicies } from '@graphcommerce/graphql'
2
- import type { CustomerToken, Mutation } from '@graphcommerce/graphql-mesh'
2
+ import type { Mutation } from '@graphcommerce/graphql-mesh'
3
3
  import { CustomerTokenDocument } from './hooks/CustomerToken.gql'
4
- import { IsEmailAvailableDocument } from './hooks/IsEmailAvailable.gql'
5
-
6
- const TOKEN_EXPIRATION_MS = 60 * 60 * 1000
7
-
8
- const valid: FieldPolicy<CustomerToken['valid']> = {
9
- read(existing, options) {
10
- if (existing === undefined) return existing
11
-
12
- const ref = options.toReference({ __ref: 'CustomerToken' })
13
- const createdAt = options.readField<string>('createdAt', ref)
14
-
15
- if (!createdAt) return existing
16
-
17
- return new Date().getTime() - new Date(createdAt).getTime() < TOKEN_EXPIRATION_MS
18
- },
19
- }
20
4
 
21
5
  const generateCustomerToken: FieldPolicy<Mutation['generateCustomerToken']> = {
22
6
  keyArgs: () => '',
23
7
  merge(_existing, incoming, options) {
24
8
  if (!options.isReference(incoming)) return incoming
25
9
 
26
- const write = () => {
27
- options.cache.writeQuery({
28
- query: CustomerTokenDocument,
29
- broadcast: true,
30
- data: {
31
- customerToken: {
32
- __typename: 'CustomerToken',
33
- token: options.readField('token', incoming) as string,
34
- createdAt: new Date().toUTCString(),
35
- valid: true,
36
- },
10
+ options.cache.writeQuery({
11
+ query: CustomerTokenDocument,
12
+ broadcast: true,
13
+ data: {
14
+ customerToken: {
15
+ __typename: 'CustomerToken',
16
+ token: options.readField('token', incoming) as string,
17
+ createdAt: new Date().toUTCString(),
18
+ valid: true,
37
19
  },
38
- })
39
- }
40
- write()
20
+ },
21
+ })
41
22
 
42
- // Broadcasts the query after the token expiration so UI gets updated
43
- setTimeout(write, TOKEN_EXPIRATION_MS)
44
23
  return incoming
45
24
  },
46
25
  }
47
26
 
48
27
  export const customerTypePolicies: StrictTypedTypePolicies = {
49
28
  Mutation: { fields: { generateCustomerToken } },
50
- CustomerToken: { fields: { valid } },
51
29
  }
52
30
 
53
31
  export const migrateCustomer: MigrateCache = (oldCache, newCache) => {