@ctx-core/graphql-client 7.1.1 → 7.2.1

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.1
4
+
5
+ ### Patch Changes
6
+
7
+ - graphql_fetch_T: fix: fn_in_http_opts?:FetchHttpOpts: optional
8
+
9
+ ## 7.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - graphql*url*: feat: + port argument: defaults to 80
14
+
15
+ ## 7.1.3
16
+
17
+ ### Patch Changes
18
+
19
+ - use fetch instead of safe_fetch
20
+ - use fetch instead of safe_fetch
21
+ - Updated dependencies
22
+ - Updated dependencies
23
+ - @ctx-core/fetch-undici@1.1.0
24
+
25
+ ## 7.1.2
26
+
27
+ ### Patch Changes
28
+
29
+ - update dependencies
30
+
3
31
  ## 7.1.1
4
32
 
5
33
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctx-core/graphql-client",
3
- "version": "7.1.1",
3
+ "version": "7.2.1",
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.2",
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",
@@ -3,5 +3,5 @@ export declare function graphql_fetch_<O1 extends unknown = unknown>(
3
3
  in_http_opts?:FetchHttpOpts
4
4
  ):graphql_fetch_T<O1>;
5
5
  export declare type graphql_fetch_T<O extends unknown = unknown> =
6
- (body:string, fn_in_http_opts:FetchHttpOpts)=>Promise<O>;
6
+ (body:string, fn_in_http_opts?:FetchHttpOpts)=>Promise<O>;
7
7
  export { graphql_fetch_ as _graphql_fetch, graphql_fetch_ as _fetch__graphql, }
@@ -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, }
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'