@graphcommerce/magento-customer 10.0.0-canary.72 → 10.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,56 +1,14 @@
1
1
  # Change Log
2
2
 
3
- ## 10.0.0-canary.72
4
-
5
- ## 10.0.0-canary.71
6
-
7
- ## 10.0.0-canary.70
8
-
9
- ### Major Changes
10
-
11
- - [#2565](https://github.com/graphcommerce-org/graphcommerce/pull/2565) [`c96dfcd`](https://github.com/graphcommerce-org/graphcommerce/commit/c96dfcdca981baca387c270ad9e2b9515cdd00cc) - Updated to Apollo Client 4 ([@paales](https://github.com/paales))
12
-
13
- ## 10.0.0-canary.69
14
-
15
- ## 10.0.0-canary.68
16
-
17
- ### Major Changes
18
-
19
- - [#2557](https://github.com/graphcommerce-org/graphcommerce/pull/2557) [`ceaadd8`](https://github.com/graphcommerce-org/graphcommerce/commit/ceaadd87f0648982a068a3b07b1fa149c9127f49) - ## Material UI v5 → v7 Migration
20
-
21
- This release upgrades Material UI from v5 to v7 with full CSS variables support. ([@paales](https://github.com/paales))
22
-
23
- ## 10.0.0-canary.67
3
+ ## 10.0.1-canary.0
24
4
 
25
5
  ### Patch Changes
26
6
 
27
- - [#2540](https://github.com/graphcommerce-org/graphcommerce/pull/2540) [`36e2bac`](https://github.com/graphcommerce-org/graphcommerce/commit/36e2bacb4fe765ce1fcd24dc36736e90bb17a7dc) - Add billingAddress permission (EDITABLE | READONLY) that controls whether the end user can update their billing address in the account section and checkout. ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
28
-
29
- ## 10.0.0-canary.66
30
-
31
- ## 10.0.0-canary.65
32
-
33
- ## 10.0.0-canary.64
7
+ - [#2568](https://github.com/graphcommerce-org/graphcommerce/pull/2568) [`dc57da4`](https://github.com/graphcommerce-org/graphcommerce/commit/dc57da4897365ddb2b779eab3ad2b3a350ed115c) - Moved from form.watch to useWatch everywhere which works even if the fields are later initialized. ([@paales](https://github.com/paales))
34
8
 
35
- ## 10.0.0-canary.63
9
+ - [#2568](https://github.com/graphcommerce-org/graphcommerce/pull/2568) [`f1b60ac`](https://github.com/graphcommerce-org/graphcommerce/commit/f1b60accf5e8fdbcba15b7567dce7ff68f37db88) - Solve issue where the cache wasn't available from the context anymore in @apollo/client@4 now uses the operation.client.cache ([@paales](https://github.com/paales))
36
10
 
37
- ## 10.0.0-canary.62
38
-
39
- ### Patch Changes
40
-
41
- - [#2553](https://github.com/graphcommerce-org/graphcommerce/pull/2553) [`66ba029`](https://github.com/graphcommerce-org/graphcommerce/commit/66ba029d2cc9dee6f8ff8c92a628d4fc0cf4d309) - Unset token when on magento 248 to prevent repeated graphql-authentication errors ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
42
-
43
- ## 10.0.0-canary.61
44
-
45
- ## 10.0.0-canary.60
46
-
47
- ## 10.0.0-canary.59
48
-
49
- ## 10.0.0-canary.58
50
-
51
- ## 10.0.0-canary.57
52
-
53
- ## 10.0.0-canary.56
11
+ ## 10.0.0
54
12
 
55
13
  ### Major Changes
56
14
 
@@ -130,93 +88,11 @@
130
88
  - `@mui/*` modern alias rewrites
131
89
  - Debug plugins (`CircularDependencyPlugin`, `DuplicatesPlugin`) ([@paales](https://github.com/paales))
132
90
 
133
- ## 9.1.0-canary.55
134
-
135
- ### Patch Changes
136
-
137
- - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`427833d`](https://github.com/graphcommerce-org/graphcommerce/commit/427833d3fa46ec6096853bdc3dfd81321df6e63b) - Forward address field props ([@paales](https://github.com/paales))
138
-
139
- - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`183d8dd`](https://github.com/graphcommerce-org/graphcommerce/commit/183d8ddef6059f07ffe585b0f05a51731b12b371) - Remove odd nonNullable that is also available in @graphcommmerce/next-ui ([@paales](https://github.com/paales))
140
-
141
- ## 9.1.0-canary.54
142
-
143
- ## 9.1.0-canary.53
144
-
145
- ## 9.1.0-canary.52
146
-
147
- ## 9.1.0-canary.51
148
-
149
- ## 9.1.0-canary.50
150
-
151
- ## 9.1.0-canary.49
152
-
153
- ## 9.1.0-canary.48
154
-
155
- ## 9.1.0-canary.47
156
-
157
- ## 9.1.0-canary.46
158
-
159
- ## 9.1.0-canary.45
160
-
161
- ## 9.1.0-canary.44
162
-
163
- ## 9.1.0-canary.43
164
-
165
- ## 9.1.0-canary.42
166
-
167
- ## 9.1.0-canary.41
168
-
169
- ## 9.1.0-canary.40
170
-
171
- ### Patch Changes
172
-
173
- - [#2529](https://github.com/graphcommerce-org/graphcommerce/pull/2529) [`b331f4d`](https://github.com/graphcommerce-org/graphcommerce/commit/b331f4d060c1385569fbbe1592ac245832de55bc) - Remove all usages of the NoSsr component as the GraphQL layer already handles this. ([@paales](https://github.com/paales))
174
-
175
- ## 9.1.0-canary.39
176
-
177
- ## 9.1.0-canary.38
178
-
179
- ## 9.1.0-canary.37
180
-
181
- ## 9.1.0-canary.36
182
-
183
- ## 9.1.0-canary.35
184
-
185
- ## 9.1.0-canary.34
186
-
187
- ## 9.1.0-canary.33
188
-
189
- ## 9.1.0-canary.32
190
-
191
- ## 9.1.0-canary.31
192
-
193
- ### Patch Changes
194
-
195
- - [#2524](https://github.com/graphcommerce-org/graphcommerce/pull/2524) [`dcc46aa`](https://github.com/graphcommerce-org/graphcommerce/commit/dcc46aae34f5eda6a633f472289ac4488ac96492) - Solve issue where the user is getting a 400 error when logging in because the password is not being sent. The password field was disabled before the form was submitted, causing the password not to be sent. ([@paales](https://github.com/paales))
196
-
197
- ## 9.1.0-canary.30
198
-
199
- ## 9.1.0-canary.29
200
-
201
- ## 9.1.0-canary.28
202
-
203
- ## 9.1.0-canary.27
204
-
205
- ## 9.1.0-canary.26
206
-
207
- ## 9.1.0-canary.25
208
-
209
- ## 9.1.0-canary.24
210
-
211
- ## 9.1.0-canary.23
212
-
213
- ## 9.1.0-canary.22
214
-
215
- ## 9.1.0-canary.21
91
+ - [#2557](https://github.com/graphcommerce-org/graphcommerce/pull/2557) [`ceaadd8`](https://github.com/graphcommerce-org/graphcommerce/commit/ceaadd87f0648982a068a3b07b1fa149c9127f49) - ## Material UI v5 → v7 Migration
216
92
 
217
- ## 9.1.0-canary.20
93
+ This release upgrades Material UI from v5 to v7 with full CSS variables support. ([@paales](https://github.com/paales))
218
94
 
219
- ## 9.1.0-canary.19
95
+ - [#2565](https://github.com/graphcommerce-org/graphcommerce/pull/2565) [`c96dfcd`](https://github.com/graphcommerce-org/graphcommerce/commit/c96dfcdca981baca387c270ad9e2b9515cdd00cc) - Updated to Apollo Client 4 ([@paales](https://github.com/paales))
220
96
 
221
97
  ### Minor Changes
222
98
 
@@ -226,67 +102,37 @@
226
102
 
227
103
  ### Patch Changes
228
104
 
229
- - [#2499](https://github.com/graphcommerce-org/graphcommerce/pull/2499) [`6cb4815`](https://github.com/graphcommerce-org/graphcommerce/commit/6cb4815a0faf4cc2f60c13d9384e3a96b6bdb2bb) - Deleting an account will now require reauthentication and moved the menu item to the Authentication section ([@paales](https://github.com/paales))
230
-
231
- - [#2499](https://github.com/graphcommerce-org/graphcommerce/pull/2499) [`2409514`](https://github.com/graphcommerce-org/graphcommerce/commit/240951428ac0bdc11649f4190b6d51c004680b34) - Order/Invoice/CreditMemo and Shipment views ([@paales](https://github.com/paales))
232
-
233
- ## 9.1.0-canary.18
234
-
235
- ## 9.1.0-canary.17
236
-
237
- ## 9.1.0-canary.16
238
-
239
- ## 9.1.0-canary.15
240
-
241
- ### Patch Changes
242
-
243
105
  - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`0cb3ace`](https://github.com/graphcommerce-org/graphcommerce/commit/0cb3aceb09967493ecdd5040446447ff32cc3f43) - Created a AccountDashboardQueryFragment instead of only a query to allow for adding customerDownloadableProducts to the dashboard query ([@paales](https://github.com/paales))
244
106
 
107
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`427833d`](https://github.com/graphcommerce-org/graphcommerce/commit/427833d3fa46ec6096853bdc3dfd81321df6e63b) - Forward address field props ([@paales](https://github.com/paales))
108
+
245
109
  - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`c1f04dc`](https://github.com/graphcommerce-org/graphcommerce/commit/c1f04dcb4ddd621361e6c930fb42afae0aabe9f9) - Migrate to default OrderItem resolver and remove useOrderCardItemImages as OrderItem now returns a product. Add a custom resolver for 2.4.5 and 2.4.6 that implements the functionality for older versions. ([@paales](https://github.com/paales))
246
110
 
247
111
  - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`c1f04dc`](https://github.com/graphcommerce-org/graphcommerce/commit/c1f04dcb4ddd621361e6c930fb42afae0aabe9f9) - Created a refactored the AccountOrders page and refactored the OrderCard. ([@paales](https://github.com/paales))
248
112
 
249
- - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`db56933`](https://github.com/graphcommerce-org/graphcommerce/commit/db569336dddd3e955ff0b5b00cafa25079f1adee) - Implemented order sorting for account overview and account list and implement custom resolver for Magento 2.4.5 (which is slow but works). ([@paales](https://github.com/paales))
250
-
251
- - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`db56933`](https://github.com/graphcommerce-org/graphcommerce/commit/db569336dddd3e955ff0b5b00cafa25079f1adee) - Use OrderStateLabel in my account instead of OrderStateLabelInline and deprecate that one. ([@paales](https://github.com/paales))
252
-
253
- - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`dc387da`](https://github.com/graphcommerce-org/graphcommerce/commit/dc387da4c32585c251fe9dec90aa010e2a435df5) - OrderTotals/OrderDetails now only renders addres information if available ([@paales](https://github.com/paales))
254
-
255
- - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`623e993`](https://github.com/graphcommerce-org/graphcommerce/commit/623e993579b05e053d2d2f29684649cd4f4586de) - `<WaitForCustomer />` now accepts all props of the FullPageMessage ([@paales](https://github.com/paales))
256
-
257
- ## 9.0.4-canary.14
258
-
259
- ## 9.0.4-canary.13
260
-
261
- ## 9.0.4-canary.12
262
-
263
- ## 9.0.4-canary.11
264
-
265
- ## 9.0.4-canary.10
113
+ - [#2540](https://github.com/graphcommerce-org/graphcommerce/pull/2540) [`36e2bac`](https://github.com/graphcommerce-org/graphcommerce/commit/36e2bacb4fe765ce1fcd24dc36736e90bb17a7dc) - Add billingAddress permission (EDITABLE | READONLY) that controls whether the end user can update their billing address in the account section and checkout. ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
266
114
 
267
- ## 9.0.4-canary.9
115
+ - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`db56933`](https://github.com/graphcommerce-org/graphcommerce/commit/db569336dddd3e955ff0b5b00cafa25079f1adee) - Implemented order sorting for account overview and account list and implement custom resolver for Magento 2.4.5 (which is slow but works). ([@paales](https://github.com/paales))
268
116
 
269
- ## 9.0.4-canary.8
117
+ - [#2499](https://github.com/graphcommerce-org/graphcommerce/pull/2499) [`6cb4815`](https://github.com/graphcommerce-org/graphcommerce/commit/6cb4815a0faf4cc2f60c13d9384e3a96b6bdb2bb) - Deleting an account will now require reauthentication and moved the menu item to the Authentication section ([@paales](https://github.com/paales))
270
118
 
271
- ## 9.0.4-canary.7
119
+ - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`db56933`](https://github.com/graphcommerce-org/graphcommerce/commit/db569336dddd3e955ff0b5b00cafa25079f1adee) - Use OrderStateLabel in my account instead of OrderStateLabelInline and deprecate that one. ([@paales](https://github.com/paales))
272
120
 
273
- ## 9.0.4-canary.6
121
+ - [#2524](https://github.com/graphcommerce-org/graphcommerce/pull/2524) [`dcc46aa`](https://github.com/graphcommerce-org/graphcommerce/commit/dcc46aae34f5eda6a633f472289ac4488ac96492) - Solve issue where the user is getting a 400 error when logging in because the password is not being sent. The password field was disabled before the form was submitted, causing the password not to be sent. ([@paales](https://github.com/paales))
274
122
 
275
- ## 9.0.4-canary.5
123
+ - [#2553](https://github.com/graphcommerce-org/graphcommerce/pull/2553) [`66ba029`](https://github.com/graphcommerce-org/graphcommerce/commit/66ba029d2cc9dee6f8ff8c92a628d4fc0cf4d309) - Unset token when on magento 248 to prevent repeated graphql-authentication errors ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
276
124
 
277
- ## 9.0.4-canary.4
125
+ - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`dc387da`](https://github.com/graphcommerce-org/graphcommerce/commit/dc387da4c32585c251fe9dec90aa010e2a435df5) - OrderTotals/OrderDetails now only renders addres information if available ([@paales](https://github.com/paales))
278
126
 
279
- ### Patch Changes
127
+ - [#2529](https://github.com/graphcommerce-org/graphcommerce/pull/2529) [`b331f4d`](https://github.com/graphcommerce-org/graphcommerce/commit/b331f4d060c1385569fbbe1592ac245832de55bc) - Remove all usages of the NoSsr component as the GraphQL layer already handles this. ([@paales](https://github.com/paales))
280
128
 
281
129
  - [`5ca6fb9`](https://github.com/graphcommerce-org/graphcommerce/commit/5ca6fb94f6f275210c77493d05bad7c1620ff5a3) - When a user reorders their cart without interacting with their cart previously a new cart wouldn't be created. ([@paales](https://github.com/paales))
282
130
 
283
- ## 9.0.4-canary.3
284
-
285
- ## 9.0.4-canary.2
131
+ - [#2499](https://github.com/graphcommerce-org/graphcommerce/pull/2499) [`2409514`](https://github.com/graphcommerce-org/graphcommerce/commit/240951428ac0bdc11649f4190b6d51c004680b34) - Order/Invoice/CreditMemo and Shipment views ([@paales](https://github.com/paales))
286
132
 
287
- ## 9.0.4-canary.1
133
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`183d8dd`](https://github.com/graphcommerce-org/graphcommerce/commit/183d8ddef6059f07ffe585b0f05a51731b12b371) - Remove odd nonNullable that is also available in @graphcommmerce/next-ui ([@paales](https://github.com/paales))
288
134
 
289
- ## 9.0.4-canary.0
135
+ - [#2493](https://github.com/graphcommerce-org/graphcommerce/pull/2493) [`623e993`](https://github.com/graphcommerce-org/graphcommerce/commit/623e993579b05e053d2d2f29684649cd4f4586de) - `<WaitForCustomer />` now accepts all props of the FullPageMessage ([@paales](https://github.com/paales))
290
136
 
291
137
  ## 9.0.0
292
138
 
@@ -10,6 +10,7 @@ import {
10
10
  FormRow,
11
11
  LayoutTitle,
12
12
  } from '@graphcommerce/next-ui'
13
+ import { useWatch } from '@graphcommerce/react-hook-form'
13
14
  import { Trans } from '@lingui/react/macro'
14
15
  import type { SxProps, Theme } from '@mui/material'
15
16
  import { Alert, Box, CircularProgress, Link, Typography } from '@mui/material'
@@ -43,7 +44,7 @@ export function AccountSignInUpForm(props: AccountSignInUpFormProps) {
43
44
  const { firstname = '' } = customerQuery.data?.customer ?? {}
44
45
 
45
46
  const { mode, form, submit } = useAccountSignInUpForm()
46
- const { formState, control, error, setError, clearErrors, watch } = form
47
+ const { formState, control, error, setError, clearErrors } = form
47
48
  const router = useRouter()
48
49
 
49
50
  const client = useApolloClient()
@@ -57,7 +58,7 @@ export function AccountSignInUpForm(props: AccountSignInUpFormProps) {
57
58
  mode === 'signin' ||
58
59
  (mode === 'signup' && canSignUp)
59
60
 
60
- const emailValue = watch('email')
61
+ const emailValue = useWatch({ control, name: 'email' })
61
62
 
62
63
  return (
63
64
  <FormDiv sx={sx} className={classes.root}>
@@ -23,11 +23,9 @@ export function SignInForm(props: SignInFormProps) {
23
23
  email,
24
24
  onBeforeSubmit(variables) {
25
25
  if (!email) {
26
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
27
26
  setError('email', { message: t`Please enter a valid email address` })
28
27
  return false
29
28
  }
30
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
31
29
  clearErrors()
32
30
  return variables
33
31
  },
@@ -9,7 +9,7 @@ import {
9
9
  FormRow,
10
10
  MessageSnackbar,
11
11
  } from '@graphcommerce/next-ui'
12
- import { emailPattern, useFormGqlMutation } from '@graphcommerce/react-hook-form'
12
+ import { emailPattern, useFormGqlMutation, useWatch } from '@graphcommerce/react-hook-form'
13
13
  import { t } from '@lingui/core/macro'
14
14
  import { Trans } from '@lingui/react/macro'
15
15
  import { ApolloCustomerErrorSnackbar } from '../ApolloCustomerError'
@@ -41,7 +41,7 @@ export function UpdateCustomerEmailForm(props: UpdateCustomerEmailFormProps) {
41
41
  },
42
42
  )
43
43
 
44
- const { handleSubmit, error, required, formState, watch, reset, control } = form
44
+ const { handleSubmit, error, required, formState, reset, control } = form
45
45
  const [remainingError, authenticationError] = graphqlErrorByCategory({
46
46
  category: 'graphql-authentication',
47
47
  error,
@@ -49,7 +49,7 @@ export function UpdateCustomerEmailForm(props: UpdateCustomerEmailFormProps) {
49
49
  const submit = handleSubmit(() => {
50
50
  reset()
51
51
  })
52
- const watchNewEmail = watch('email')
52
+ const watchNewEmail = useWatch({ control, name: 'email' })
53
53
 
54
54
  return (
55
55
  <Form onSubmit={submit} noValidate>
@@ -2,7 +2,7 @@ import { usePageContext } from '@graphcommerce/framer-next-pages'
2
2
  import { useQuery } from '@graphcommerce/graphql'
3
3
  import { enableGuestCheckoutLogin } from '@graphcommerce/next-config/config'
4
4
  import { useUrlQuery } from '@graphcommerce/next-ui'
5
- import { useFormGqlQuery } from '@graphcommerce/react-hook-form'
5
+ import { useFormGqlQuery, useWatch } from '@graphcommerce/react-hook-form'
6
6
  import { useEffect } from 'react'
7
7
  import type { IsEmailAvailableQuery, IsEmailAvailableQueryVariables } from './IsEmailAvailable.gql'
8
8
  import { IsEmailAvailableDocument } from './IsEmailAvailable.gql'
@@ -40,8 +40,9 @@ export function useAccountSignInUpForm(props: UseFormIsEmailAvailableProps = {})
40
40
  },
41
41
  { fetchPolicy: 'cache-and-network' },
42
42
  )
43
- const { formState, data, handleSubmit, setValue, trigger } = form
43
+ const { formState, data, handleSubmit, setValue, trigger, control } = form
44
44
  const { isSubmitSuccessful, isValid } = formState
45
+ const requestedMode = useWatch({ control, name: 'requestedMode' })
45
46
 
46
47
  useEffect(() => {
47
48
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
@@ -68,7 +69,7 @@ export function useAccountSignInUpForm(props: UseFormIsEmailAvailableProps = {})
68
69
  if (token && valid) mode = 'signedin'
69
70
  else if (token && !valid) mode = 'session-expired'
70
71
  else if (isToggleMethod) {
71
- mode = form.watch('requestedMode') ?? 'signin'
72
+ mode = requestedMode ?? 'signin'
72
73
  } else {
73
74
  // 1. Nothing is entered
74
75
  mode = 'email'
@@ -1,5 +1,3 @@
1
- import { globalApolloClient } from '@graphcommerce/graphql'
2
- import type { ApolloCache } from '@graphcommerce/graphql/apollo'
3
1
  import {
4
2
  ApolloLink,
5
3
  CombinedGraphQLErrors,
@@ -17,7 +15,6 @@ export type PushRouter = Pick<NextRouter, 'push' | 'events' | 'locale'>
17
15
 
18
16
  declare module '@apollo/client' {
19
17
  interface DefaultContext {
20
- cache?: ApolloCache
21
18
  headers?: Record<string, string>
22
19
  }
23
20
  }
@@ -51,25 +48,24 @@ export async function pushWithPromise(router: Pick<NextRouter, 'push' | 'events'
51
48
  })
52
49
  }
53
50
 
54
- const addTokenHeader = new SetContextLink((prevContext) => {
51
+ const addTokenHeader = new SetContextLink((prevContext, operation) => {
55
52
  const headers: Record<string, string> = { ...prevContext.headers }
56
53
 
57
54
  try {
58
- const query = prevContext.cache?.readQuery({ query: CustomerTokenDocument })
55
+ const query = operation.client.cache.readQuery({ query: CustomerTokenDocument })
59
56
 
60
57
  if (query?.customerToken?.token && query?.customerToken?.valid !== false) {
61
58
  headers.authorization = `Bearer ${query?.customerToken?.token}`
62
59
  }
63
60
  return { headers }
64
- } catch (error) {
61
+ } catch {
65
62
  return { headers }
66
63
  }
67
64
  })
68
65
 
69
66
  const customerErrorLink = (router: PushRouter) =>
70
67
  new ErrorLink(({ error, operation, forward }) => {
71
- const client = globalApolloClient.current
72
- if (!client) return undefined
68
+ const { client } = operation
73
69
 
74
70
  // Check if this is a GraphQL error
75
71
  if (!CombinedGraphQLErrors.is(error)) return undefined
@@ -4,9 +4,11 @@ import { map } from '@graphcommerce/graphql/rxjs'
4
4
  import { CustomerTokenDocument } from '../hooks'
5
5
 
6
6
  export const xMagentoCacheIdHeader = new ApolloLink((operation, forward) => {
7
+ const { cache } = operation.client
8
+
7
9
  operation.setContext((context: DefaultContext) => {
8
- const xMagentoCacheId = context.cache?.readQuery({ query: CustomerTokenDocument })
9
- ?.customerToken?.xMagentoCacheId
10
+ const xMagentoCacheId = cache?.readQuery({ query: CustomerTokenDocument })?.customerToken
11
+ ?.xMagentoCacheId
10
12
  if (!xMagentoCacheId) return context
11
13
 
12
14
  return { ...context, headers: { ...context.headers, 'x-magento-cache-id': xMagentoCacheId } }
@@ -14,7 +16,6 @@ export const xMagentoCacheIdHeader = new ApolloLink((operation, forward) => {
14
16
 
15
17
  return forward(operation).pipe(
16
18
  map((data) => {
17
- const { cache } = operation.getContext()
18
19
  if (!cache) return data
19
20
 
20
21
  const xMagentoCacheId = (
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": "10.0.0-canary.72",
5
+ "version": "10.0.1-canary.0",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -21,20 +21,20 @@
21
21
  "./plugins/magentoCustomerPrivateQueryContext": "./plugins/magentoCustomerPrivateQueryContext.ts"
22
22
  },
23
23
  "peerDependencies": {
24
- "@graphcommerce/ecommerce-ui": "^10.0.0-canary.72",
25
- "@graphcommerce/eslint-config-pwa": "^10.0.0-canary.72",
26
- "@graphcommerce/framer-next-pages": "^10.0.0-canary.72",
27
- "@graphcommerce/framer-utils": "^10.0.0-canary.72",
28
- "@graphcommerce/graphql": "^10.0.0-canary.72",
29
- "@graphcommerce/graphql-mesh": "^10.0.0-canary.72",
30
- "@graphcommerce/image": "^10.0.0-canary.72",
31
- "@graphcommerce/magento-graphql": "^10.0.0-canary.72",
32
- "@graphcommerce/magento-store": "^10.0.0-canary.72",
33
- "@graphcommerce/next-config": "^10.0.0-canary.72",
34
- "@graphcommerce/next-ui": "^10.0.0-canary.72",
35
- "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.72",
36
- "@graphcommerce/react-hook-form": "^10.0.0-canary.72",
37
- "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.72",
24
+ "@graphcommerce/ecommerce-ui": "^10.0.1-canary.0",
25
+ "@graphcommerce/eslint-config-pwa": "^10.0.1-canary.0",
26
+ "@graphcommerce/framer-next-pages": "^10.0.1-canary.0",
27
+ "@graphcommerce/framer-utils": "^10.0.1-canary.0",
28
+ "@graphcommerce/graphql": "^10.0.1-canary.0",
29
+ "@graphcommerce/graphql-mesh": "^10.0.1-canary.0",
30
+ "@graphcommerce/image": "^10.0.1-canary.0",
31
+ "@graphcommerce/magento-graphql": "^10.0.1-canary.0",
32
+ "@graphcommerce/magento-store": "^10.0.1-canary.0",
33
+ "@graphcommerce/next-config": "^10.0.1-canary.0",
34
+ "@graphcommerce/next-ui": "^10.0.1-canary.0",
35
+ "@graphcommerce/prettier-config-pwa": "^10.0.1-canary.0",
36
+ "@graphcommerce/react-hook-form": "^10.0.1-canary.0",
37
+ "@graphcommerce/typescript-config-pwa": "^10.0.1-canary.0",
38
38
  "@lingui/core": "^5",
39
39
  "@lingui/macro": "^5",
40
40
  "@lingui/react": "^5",
package/typePolicies.ts CHANGED
@@ -5,15 +5,22 @@ import { CustomerTokenDocument } from './hooks/CustomerToken.gql'
5
5
  const generateCustomerToken: FieldPolicy<Mutation['generateCustomerToken']> = {
6
6
  keyArgs: () => '',
7
7
  merge(_existing, incoming, options) {
8
+ console.log('[generateCustomerToken] merge called', {
9
+ isReference: options.isReference(incoming),
10
+ incoming,
11
+ })
8
12
  if (!options.isReference(incoming)) return incoming
9
13
 
14
+ const token = options.readField('token', incoming) as string
15
+ console.log('[generateCustomerToken] Writing token to cache:', token?.substring(0, 20))
16
+
10
17
  options.cache.writeQuery({
11
18
  query: CustomerTokenDocument,
12
19
  broadcast: true,
13
20
  data: {
14
21
  customerToken: {
15
22
  __typename: 'CustomerToken',
16
- token: options.readField('token', incoming) as string,
23
+ token,
17
24
  createdAt: new Date().toUTCString(),
18
25
  valid: true,
19
26
  xMagentoCacheId: null,
@@ -21,6 +28,10 @@ const generateCustomerToken: FieldPolicy<Mutation['generateCustomerToken']> = {
21
28
  },
22
29
  })
23
30
 
31
+ // Verify write
32
+ const verify = options.cache.readQuery({ query: CustomerTokenDocument })
33
+ console.log('[generateCustomerToken] Verify after write:', verify)
34
+
24
35
  return incoming
25
36
  },
26
37
  }