@ctx-core/graphql-client 7.2.10 → 7.2.11
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/package.json +2 -2
- package/src/graphql_fetch_.js +4 -6
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctx-core/graphql-client",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.11",
|
|
4
4
|
"description": "ctx-core graphql-client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ctx-core",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@ctx-core/object": "*"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "^17.0.
|
|
34
|
+
"@types/node": "^17.0.18",
|
|
35
35
|
"c8": "^7.11.0",
|
|
36
36
|
"check-dts": "^0.6.6",
|
|
37
37
|
"tsm": "^2.2.1",
|
package/src/graphql_fetch_.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fetch_response_pair_ } from '@ctx-core/fetch-undici'
|
|
2
2
|
import { assign } from '@ctx-core/object'
|
|
3
3
|
export function graphql_fetch_(in_http_opts = {}) {
|
|
4
4
|
return async function graphql_fetch(body, fn_in_http_opts = {}) {
|
|
@@ -6,7 +6,7 @@ export function graphql_fetch_(in_http_opts = {}) {
|
|
|
6
6
|
if (!url) {
|
|
7
7
|
throw `no url prop`
|
|
8
8
|
}
|
|
9
|
-
const response = await
|
|
9
|
+
const [payload, response] = await fetch_response_pair_(url, assign({
|
|
10
10
|
method: 'POST',
|
|
11
11
|
headers: assign({
|
|
12
12
|
'Content-Type': 'application/json'
|
|
@@ -14,16 +14,14 @@ export function graphql_fetch_(in_http_opts = {}) {
|
|
|
14
14
|
body
|
|
15
15
|
}, in_http_opts, fn_in_http_opts))
|
|
16
16
|
if (response.ok) {
|
|
17
|
-
const payload = await response.json()
|
|
18
17
|
if (payload.errors) throw payload
|
|
19
18
|
return payload
|
|
20
19
|
} else {
|
|
21
|
-
const error_text = await response.text()
|
|
22
20
|
if (process.env.NODE_ENV === 'production') {
|
|
23
|
-
console.error(
|
|
21
|
+
console.error(payload)
|
|
24
22
|
throw `Error fetching graphql`
|
|
25
23
|
} else {
|
|
26
|
-
throw
|
|
24
|
+
throw payload
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
}
|