@ctx-core/graphql-client 7.1.3 → 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,11 @@
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
+
3
9
  ## 7.1.3
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctx-core/graphql-client",
3
- "version": "7.1.3",
3
+ "version": "7.2.0",
4
4
  "description": "ctx-core graphql-client",
5
5
  "keywords": [
6
6
  "ctx-core",
@@ -27,11 +27,11 @@
27
27
  "dependencies": {
28
28
  "@ctx-core/dom": "^11.1.5",
29
29
  "@ctx-core/fetch-undici": "^1.1.0",
30
- "@ctx-core/graphql": "^9.0.55",
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",
@@ -13,7 +13,11 @@ 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 {
17
21
  const error_text = await response.text()
18
22
  if (process.env.NODE_ENV === 'production') {
19
23
  console.error(error_text)
@@ -22,9 +26,6 @@ export function graphql_fetch_(in_http_opts = {}) {
22
26
  throw error_text
23
27
  }
24
28
  }
25
- const payload = await response.json()
26
- if (payload.errors) throw payload
27
- return payload
28
29
  }
29
30
  }
30
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, }