@graphcommerce/magento-customer 10.0.0-canary.61 → 10.0.0-canary.62
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 +6 -0
- package/link/customerLink.ts +8 -7
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.0.0-canary.62
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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))
|
|
8
|
+
|
|
3
9
|
## 10.0.0-canary.61
|
|
4
10
|
|
|
5
11
|
## 10.0.0-canary.60
|
package/link/customerLink.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { globalApolloClient } from '@graphcommerce/graphql'
|
|
2
2
|
import type { ApolloCache } from '@graphcommerce/graphql/apollo'
|
|
3
3
|
import { ApolloLink, fromPromise, onError, setContext } from '@graphcommerce/graphql/apollo'
|
|
4
|
-
import
|
|
4
|
+
import { magentoVersion } from '@graphcommerce/next-config/config'
|
|
5
5
|
import type { GraphQLFormattedError } from 'graphql'
|
|
6
6
|
import type { NextRouter } from 'next/router'
|
|
7
7
|
import { signOut } from '../components/SignOutForm/signOut'
|
|
@@ -45,17 +45,13 @@ export async function pushWithPromise(router: Pick<NextRouter, 'push' | 'events'
|
|
|
45
45
|
})
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function isErrorCategory(err: GraphQLFormattedError, category: ErrorCategory) {
|
|
49
|
-
return err.extensions?.category === category
|
|
50
|
-
}
|
|
51
|
-
|
|
52
48
|
const addTokenHeader = setContext((_, context) => {
|
|
53
49
|
if (!context.headers) context.headers = {}
|
|
54
50
|
|
|
55
51
|
try {
|
|
56
52
|
const query = context.cache?.readQuery({ query: CustomerTokenDocument })
|
|
57
53
|
|
|
58
|
-
if (query?.customerToken?.token) {
|
|
54
|
+
if (query?.customerToken?.token && query?.customerToken?.valid !== false) {
|
|
59
55
|
context.headers.authorization = `Bearer ${query?.customerToken?.token}`
|
|
60
56
|
return context
|
|
61
57
|
}
|
|
@@ -72,7 +68,12 @@ const customerErrorLink = (router: PushRouter) =>
|
|
|
72
68
|
if (!client) return undefined
|
|
73
69
|
|
|
74
70
|
const oldHeaders = operation.getContext().headers
|
|
75
|
-
|
|
71
|
+
|
|
72
|
+
const authError = graphQLErrors?.find(
|
|
73
|
+
(err: GraphQLFormattedError) =>
|
|
74
|
+
err.extensions?.category ===
|
|
75
|
+
(magentoVersion >= 248 ? 'graphql-authentication' : 'graphql-authorization'),
|
|
76
|
+
)
|
|
76
77
|
|
|
77
78
|
/** If the error we're dealing with is not an authorization error, we're done. */
|
|
78
79
|
if (!authError) return undefined
|
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.
|
|
5
|
+
"version": "10.0.0-canary.62",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
"./plugins/magentoCustomerPrivateQueryContext": "./plugins/magentoCustomerPrivateQueryContext.ts"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@graphcommerce/ecommerce-ui": "^10.0.0-canary.
|
|
25
|
-
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.
|
|
26
|
-
"@graphcommerce/framer-next-pages": "^10.0.0-canary.
|
|
27
|
-
"@graphcommerce/framer-utils": "^10.0.0-canary.
|
|
28
|
-
"@graphcommerce/graphql": "^10.0.0-canary.
|
|
29
|
-
"@graphcommerce/graphql-mesh": "^10.0.0-canary.
|
|
30
|
-
"@graphcommerce/image": "^10.0.0-canary.
|
|
31
|
-
"@graphcommerce/magento-graphql": "^10.0.0-canary.
|
|
32
|
-
"@graphcommerce/magento-store": "^10.0.0-canary.
|
|
33
|
-
"@graphcommerce/next-ui": "^10.0.0-canary.
|
|
34
|
-
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.
|
|
35
|
-
"@graphcommerce/react-hook-form": "^10.0.0-canary.
|
|
36
|
-
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.
|
|
24
|
+
"@graphcommerce/ecommerce-ui": "^10.0.0-canary.62",
|
|
25
|
+
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.62",
|
|
26
|
+
"@graphcommerce/framer-next-pages": "^10.0.0-canary.62",
|
|
27
|
+
"@graphcommerce/framer-utils": "^10.0.0-canary.62",
|
|
28
|
+
"@graphcommerce/graphql": "^10.0.0-canary.62",
|
|
29
|
+
"@graphcommerce/graphql-mesh": "^10.0.0-canary.62",
|
|
30
|
+
"@graphcommerce/image": "^10.0.0-canary.62",
|
|
31
|
+
"@graphcommerce/magento-graphql": "^10.0.0-canary.62",
|
|
32
|
+
"@graphcommerce/magento-store": "^10.0.0-canary.62",
|
|
33
|
+
"@graphcommerce/next-ui": "^10.0.0-canary.62",
|
|
34
|
+
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.62",
|
|
35
|
+
"@graphcommerce/react-hook-form": "^10.0.0-canary.62",
|
|
36
|
+
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.62",
|
|
37
37
|
"@lingui/core": "^5",
|
|
38
38
|
"@lingui/macro": "^5",
|
|
39
39
|
"@lingui/react": "^5",
|