@ctx-core/graphql-client 7.1.0 → 7.2.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,5 +1,33 @@
1
1
  # @ctx-core/graphql-client
2
2
 
3
+ ## 7.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - graphql*url*: feat: + port argument: defaults to 80
8
+
9
+ ## 7.1.3
10
+
11
+ ### Patch Changes
12
+
13
+ - use fetch instead of safe_fetch
14
+ - use fetch instead of safe_fetch
15
+ - Updated dependencies
16
+ - Updated dependencies
17
+ - @ctx-core/fetch-undici@1.1.0
18
+
19
+ ## 7.1.2
20
+
21
+ ### Patch Changes
22
+
23
+ - update dependencies
24
+
25
+ ## 7.1.1
26
+
27
+ ### Patch Changes
28
+
29
+ - update dependencies
30
+
3
31
  ## 7.1.0
4
32
 
5
33
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctx-core/graphql-client",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "description": "ctx-core graphql-client",
5
5
  "keywords": [
6
6
  "ctx-core",
@@ -26,12 +26,12 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@ctx-core/dom": "^11.1.5",
29
- "@ctx-core/fetch-undici": "^1.0.0",
30
- "@ctx-core/graphql": "^9.0.55",
29
+ "@ctx-core/fetch-undici": "^1.1.0",
30
+ "@ctx-core/graphql": "^9.0.56",
31
31
  "@ctx-core/object": "^22.0.13"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/node": "^17.0.10",
34
+ "@types/node": "^17.0.13",
35
35
  "c8": "^7.11.0",
36
36
  "check-dts": "^0.6.6",
37
37
  "tsm": "^2.2.1",
@@ -1,4 +1,4 @@
1
- import { safe_fetch as fetch } from '@ctx-core/fetch-undici'
1
+ import { fetch } 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 = {}) {
@@ -13,17 +13,19 @@ export function graphql_fetch_(in_http_opts = {}) {
13
13
  }, in_http_opts.headers, fn_in_http_opts.headers),
14
14
  body
15
15
  }, in_http_opts, fn_in_http_opts))
16
- if (!response.ok) {
16
+ if (response.ok) {
17
+ const payload = await response.json()
18
+ if (payload.errors) throw payload
19
+ return payload
20
+ } else {
21
+ const error_text = await response.text()
17
22
  if (process.env.NODE_ENV === 'production') {
18
- console.error(await response.text())
23
+ console.error(error_text)
19
24
  throw `Error fetching graphql`
20
25
  } else {
21
- throw await response.text()
26
+ throw error_text
22
27
  }
23
28
  }
24
- const payload = await response.json()
25
- if (payload.errors) throw payload
26
- return payload
27
29
  }
28
30
  }
29
31
  export { graphql_fetch_ as _graphql_fetch, graphql_fetch_ as _fetch__graphql, }
@@ -1,2 +1,2 @@
1
- export declare function graphql_url_(host?:string):string;
1
+ export declare function graphql_url_(host?:string, port?:number):string;
2
2
  export { graphql_url_ as _graphql_url, graphql_url_ as _url__graphql, }
@@ -1,8 +1,8 @@
1
1
  import { has_dom } from '@ctx-core/dom'
2
2
  import { graphql_port_txt_ } from './graphql_port_txt_.js'
3
- export function graphql_url_(host = '127.0.0.1') {
3
+ export function graphql_url_(host = '127.0.0.1', port = 80) {
4
4
  if (has_dom) return '/graphql'
5
- const host_port = `${host}${graphql_port_txt_()}`
5
+ const host_port = `${host}${graphql_port_txt_(port)}`
6
6
  return `http://${host_port}/graphql`
7
7
  }
8
8
  export { graphql_url_ as _graphql_url, graphql_url_ as _url__graphql, }