@graphcommerce/graphql 2.105.2 → 2.105.3
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/errorLink.ts +29 -0
- package/index.ts +1 -0
- package/package.json +2 -2
package/errorLink.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { onError } from '@apollo/client/link/error'
|
|
2
|
+
|
|
3
|
+
export const errorLink = onError(({ graphQLErrors, networkError, operation }) => {
|
|
4
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5
|
+
if (graphQLErrors)
|
|
6
|
+
console.error(
|
|
7
|
+
`[GraphQL errors]: ${graphQLErrors
|
|
8
|
+
.map(({ message, path }) => `${message} ${path?.join(',')}`)
|
|
9
|
+
.join(', ')}`,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
if (networkError)
|
|
13
|
+
console.error(`[Graphql error]: ${networkError}`)
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
16
|
+
;(async () => {
|
|
17
|
+
const graphql = await import('graphql')
|
|
18
|
+
|
|
19
|
+
const gqlString = graphql
|
|
20
|
+
.print(operation.query)
|
|
21
|
+
.toString()
|
|
22
|
+
.replace(/(\r\n|\n|\r)/gm, ' ')
|
|
23
|
+
.replace(/\s\s+/g, ' ')
|
|
24
|
+
|
|
25
|
+
console.error(`[GraphQL operation]: ${gqlString}`)
|
|
26
|
+
console.error(`[GraphQL variables]: ${JSON.stringify(operation.variables)}`)
|
|
27
|
+
})()
|
|
28
|
+
}
|
|
29
|
+
})
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphcommerce/graphql",
|
|
3
|
-
"version": "2.105.
|
|
3
|
+
"version": "2.105.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"react": "^17.0.2",
|
|
28
28
|
"react-dom": "^17.0.2"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "7aca802dd74632aa2f474eae2d93bd563490fd90"
|
|
31
31
|
}
|