@graphcommerce/magento-customer 6.0.2-canary.12 → 6.0.2-canary.13

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,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 6.0.2-canary.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1869](https://github.com/graphcommerce-org/graphcommerce/pull/1869) [`82111fa35`](https://github.com/graphcommerce-org/graphcommerce/commit/82111fa351b68a76ff053ebb7e0261ee507a826d) - Revert to classical useEffect strategy for Apollo cache persist restore and remove custom hydration strategies from the cart. ([@paales](https://github.com/paales))
8
+
3
9
  ## 6.0.2-canary.12
4
10
 
5
11
  ## 6.0.2-canary.11
@@ -10,16 +10,8 @@ import { useCustomerSession } from './useCustomerSession'
10
10
  /** Will only execute when the customer is signed in. */
11
11
  export function useCustomerQuery<Q, V extends OperationVariables>(
12
12
  document: TypedDocumentNode<Q, V>,
13
- options: QueryHookOptions<Q, V> & { hydration?: boolean } = {},
13
+ options: QueryHookOptions<Q, V> = {},
14
14
  ): QueryResult<Q, V> {
15
- const { hydration, ...queryOptions } = options
16
- const { loggedIn } = useCustomerSession({ hydration })
17
-
18
- const result = useQuery(document, {
19
- ...queryOptions,
20
- ssr: false,
21
- skip: !loggedIn,
22
- })
23
-
24
- return result
15
+ const { loggedIn } = useCustomerSession()
16
+ return useQuery(document, { ...options, ssr: false, skip: !loggedIn })
25
17
  }
@@ -1,13 +1,11 @@
1
- import { useIsomorphicLayoutEffect } from '@graphcommerce/framer-utils'
2
1
  import { QueryResult, useQuery } from '@graphcommerce/graphql'
3
- import { startTransition, useState } from 'react'
4
2
  import {
5
3
  CustomerTokenDocument,
6
4
  CustomerTokenQuery,
7
5
  CustomerTokenQueryVariables,
8
6
  } from './CustomerToken.gql'
9
7
 
10
- export type UseCustomerSessionOptions = { hydration?: boolean }
8
+ export type UseCustomerSessionOptions = Record<string, unknown>
11
9
 
12
10
  export type UseCustomerSessionReturn =
13
11
  | {
@@ -16,33 +14,9 @@ export type UseCustomerSessionReturn =
16
14
  query: QueryResult<CustomerTokenQuery, CustomerTokenQueryVariables>
17
15
  } & Partial<Omit<NonNullable<CustomerTokenQuery['customerToken']>, '__typename'>>
18
16
 
19
- export function useCustomerSession(options: UseCustomerSessionOptions = {}) {
20
- /**
21
- * We current always assume the initial render is during hydration.
22
- *
23
- * How can we determine we're not actually hydrating? Classically you could just use some global
24
- * state to track this because when the initial render is done, we're not hydrating anymore.
25
- *
26
- * However, <Suspense/> can be used to defer the rendering to a later moment. This means that the
27
- * useCustomerSession hook is called later and we're still in the hydration phase for this
28
- * component while other components are rendering for the second time.
29
- */
30
- const { hydration = false } = options
31
- const [hydrating, setHydrating] = useState(!hydration)
32
-
33
- /**
34
- * After the initital render we are definitely sure we're not hydrating anymore so we can flip the
35
- * switch and rerender.
36
- */
37
- useIsomorphicLayoutEffect(() => {
38
- if (!hydrating) return
39
- startTransition(() => setHydrating(false))
40
- }, [hydrating])
41
-
42
- const skip = hydrating
43
-
44
- const query = useQuery(CustomerTokenDocument, { skip })
45
-
17
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
18
+ export function useCustomerSession(_: UseCustomerSessionOptions = {}) {
19
+ const query = useQuery(CustomerTokenDocument)
46
20
  const token = query.data?.customerToken
47
21
 
48
22
  return {
@@ -9,8 +9,8 @@ import { useCustomerSession } from './useCustomerSession'
9
9
  /** Will only execute when the customer is not signed in. */
10
10
  export function useGuestQuery<Q, V extends OperationVariables>(
11
11
  document: TypedDocumentNode<Q, V>,
12
- queryOptions: QueryHookOptions<Q, V> & { hydration?: boolean } = {},
12
+ queryOptions: QueryHookOptions<Q, V> = {},
13
13
  ) {
14
- const { token } = useCustomerSession({ hydration: queryOptions.hydration })
14
+ const { token } = useCustomerSession()
15
15
  return useQuery(document, { ...queryOptions, ssr: false, skip: !!token })
16
16
  }
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": "6.0.2-canary.12",
5
+ "version": "6.0.2-canary.13",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,20 +12,20 @@
12
12
  }
13
13
  },
14
14
  "devDependencies": {
15
- "@graphcommerce/eslint-config-pwa": "6.0.2-canary.12",
16
- "@graphcommerce/prettier-config-pwa": "6.0.2-canary.12",
17
- "@graphcommerce/typescript-config-pwa": "6.0.2-canary.12"
15
+ "@graphcommerce/eslint-config-pwa": "6.0.2-canary.13",
16
+ "@graphcommerce/prettier-config-pwa": "6.0.2-canary.13",
17
+ "@graphcommerce/typescript-config-pwa": "6.0.2-canary.13"
18
18
  },
19
19
  "dependencies": {
20
- "@graphcommerce/ecommerce-ui": "6.0.2-canary.12",
21
- "@graphcommerce/framer-utils": "6.0.2-canary.12",
22
- "@graphcommerce/graphql": "6.0.2-canary.12",
23
- "@graphcommerce/graphql-mesh": "6.0.2-canary.12",
24
- "@graphcommerce/image": "6.0.2-canary.12",
25
- "@graphcommerce/magento-graphql": "6.0.2-canary.12",
26
- "@graphcommerce/magento-store": "6.0.2-canary.12",
27
- "@graphcommerce/next-ui": "6.0.2-canary.12",
28
- "@graphcommerce/react-hook-form": "6.0.2-canary.12"
20
+ "@graphcommerce/ecommerce-ui": "6.0.2-canary.13",
21
+ "@graphcommerce/framer-utils": "6.0.2-canary.13",
22
+ "@graphcommerce/graphql": "6.0.2-canary.13",
23
+ "@graphcommerce/graphql-mesh": "6.0.2-canary.13",
24
+ "@graphcommerce/image": "6.0.2-canary.13",
25
+ "@graphcommerce/magento-graphql": "6.0.2-canary.13",
26
+ "@graphcommerce/magento-store": "6.0.2-canary.13",
27
+ "@graphcommerce/next-ui": "6.0.2-canary.13",
28
+ "@graphcommerce/react-hook-form": "6.0.2-canary.13"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@lingui/react": "^3.13.2",