@graphcommerce/magento-graphql 10.0.0-canary.68 → 10.0.0-canary.72

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,13 @@
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
+ ## 10.0.0-canary.69
10
+
3
11
  ## 10.0.0-canary.68
4
12
 
5
13
  ## 10.0.0-canary.67
@@ -1,4 +1,5 @@
1
- import { ApolloError } from '@graphcommerce/graphql'
1
+ import type { ErrorLike } from '@apollo/client'
2
+ import { CombinedGraphQLErrors } from '@apollo/client/errors'
2
3
  import type { GraphQLFormattedError } from 'graphql'
3
4
 
4
5
  export type ErrorCategory =
@@ -11,7 +12,7 @@ export type ErrorCategory =
11
12
 
12
13
  export type GraphQLErrorByCategoryProps = {
13
14
  category: ErrorCategory
14
- error?: ApolloError | null
15
+ error?: ErrorLike | null
15
16
  extract?: true
16
17
  mask?: string
17
18
  }
@@ -28,30 +29,34 @@ export type GraphQLErrorByCategoryPropsNoExtract = Omit<GraphQLErrorByCategoryPr
28
29
  */
29
30
  export function graphqlErrorByCategory(
30
31
  props: GraphQLErrorByCategoryPropsNoExtract,
31
- ): [ApolloError, GraphQLFormattedError | undefined]
32
+ ): [ErrorLike, GraphQLFormattedError | undefined]
32
33
  export function graphqlErrorByCategory(
33
34
  props: GraphQLErrorByCategoryProps,
34
- ): [ApolloError | undefined, GraphQLFormattedError | undefined]
35
+ ): [ErrorLike | undefined, GraphQLFormattedError | undefined]
35
36
  export function graphqlErrorByCategory(
36
37
  props: GraphQLErrorByCategoryProps | GraphQLErrorByCategoryPropsNoExtract,
37
- ): [ApolloError | undefined, GraphQLFormattedError | undefined] {
38
+ ): [ErrorLike | undefined, GraphQLFormattedError | undefined] {
38
39
  const { category, error, extract = true, mask } = props
39
40
 
40
41
  if (!error) return [undefined, undefined]
41
42
 
42
- const newError = new ApolloError({
43
- ...error,
44
- graphQLErrors: error.graphQLErrors.filter(
45
- (err) => !extract || err?.extensions?.category !== category,
46
- ),
47
- })
43
+ // Check if this is a CombinedGraphQLErrors
44
+ if (!CombinedGraphQLErrors.is(error)) {
45
+ // Not a GraphQL error, return as-is
46
+ return [error, undefined]
47
+ }
48
+
49
+ const filteredErrors = error.errors.filter(
50
+ (err) => !extract || err?.extensions?.category !== category,
51
+ )
52
+
53
+ const newError =
54
+ filteredErrors.length > 0 ? new CombinedGraphQLErrors({ errors: filteredErrors }) : undefined
48
55
 
49
- let graphqlError = error.graphQLErrors.find((err) => err?.extensions?.category === category)
56
+ let graphqlError = error.errors.find((err) => err?.extensions?.category === category)
50
57
  if (mask && graphqlError) {
51
58
  graphqlError = { ...graphqlError, message: mask }
52
59
  }
53
60
 
54
- return newError.graphQLErrors.length === 0 && !newError.networkError
55
- ? [undefined, graphqlError]
56
- : [newError, graphqlError]
61
+ return [newError, graphqlError]
57
62
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-graphql",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "10.0.0-canary.68",
5
+ "version": "10.0.0-canary.72",
6
6
  "sideEffects": false,
7
7
  "main": "index.ts",
8
8
  "prettier": "@graphcommerce/prettier-config-pwa",
@@ -25,10 +25,10 @@
25
25
  "./mesh/magentoOrderItemResolvers.ts": "./mesh/magentoOrderItemResolvers.ts"
26
26
  },
27
27
  "peerDependencies": {
28
- "@graphcommerce/eslint-config-pwa": "^10.0.0-canary.68",
29
- "@graphcommerce/graphql": "^10.0.0-canary.68",
30
- "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.68",
31
- "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.68",
28
+ "@graphcommerce/eslint-config-pwa": "^10.0.0-canary.72",
29
+ "@graphcommerce/graphql": "^10.0.0-canary.72",
30
+ "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.72",
31
+ "@graphcommerce/typescript-config-pwa": "^10.0.0-canary.72",
32
32
  "graphql": "^16.0.0",
33
33
  "next": "*",
34
34
  "react": "^19.2.0",