@ctx-core/graphql-client 7.1.3 → 7.2.4

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,39 @@
1
1
  # @ctx-core/graphql-client
2
2
 
3
+ ## 7.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - update dependencies
8
+ - Updated dependencies
9
+ - @ctx-core/fetch-undici@1.1.3
10
+
11
+ ## 7.2.3
12
+
13
+ ### Patch Changes
14
+
15
+ - 9c361b0c8: update dependencies
16
+ - Updated dependencies [9c361b0c8]
17
+ - @ctx-core/fetch-undici@1.1.2
18
+
19
+ ## 7.2.2
20
+
21
+ ### Patch Changes
22
+
23
+ - graphql*fetch*,graphql_fetch_T: fix: return type: Promise<graphql_fetch_response_T<O>>
24
+
25
+ ## 7.2.1
26
+
27
+ ### Patch Changes
28
+
29
+ - graphql_fetch_T: fix: fn_in_http_opts?:FetchHttpOpts: optional
30
+
31
+ ## 7.2.0
32
+
33
+ ### Minor Changes
34
+
35
+ - graphql*url*: feat: + port argument: defaults to 80
36
+
3
37
  ## 7.1.3
4
38
 
5
39
  ### 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.4",
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.1.0",
30
- "@ctx-core/graphql": "^9.0.55",
29
+ "@ctx-core/fetch-undici": "^1.1.3",
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,7 +1,8 @@
1
1
  import type { FetchHttpOpts } from './_types'
2
+ import type { graphql_fetch_response_T } from './graphql_fetch'
2
3
  export declare function graphql_fetch_<O1 extends unknown = unknown>(
3
4
  in_http_opts?:FetchHttpOpts
4
5
  ):graphql_fetch_T<O1>;
5
6
  export declare type graphql_fetch_T<O extends unknown = unknown> =
6
- (body:string, fn_in_http_opts:FetchHttpOpts)=>Promise<O>;
7
+ (body:string, fn_in_http_opts?:FetchHttpOpts)=>Promise<graphql_fetch_response_T<O>>;
7
8
  export { graphql_fetch_ as _graphql_fetch, graphql_fetch_ as _fetch__graphql, }
@@ -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, }
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './_types'
2
+ export * from './graphql_fetch'
2
3
  export * from './graphql_fetch_'
3
4
  export * from './graphql_port_txt_'
4
5
  export * from './graphql_url_'
5
- export * from './graphql_fetch'
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
+ export * from './graphql_fetch.js'
1
2
  export * from './graphql_fetch_.js'
2
3
  export * from './graphql_port_txt_.js'
3
4
  export * from './graphql_url_.js'
4
- export * from './graphql_fetch.js'