@ctx-core/graphql-client 7.0.123 → 7.1.2

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.json +18 -18
  3. package/src/{FetchHttpHeaders.ts → _types/FetchHttpHeaders.d.ts} +1 -1
  4. package/src/_types/FetchHttpOpts.d.ts +5 -0
  5. package/src/_types/index.d.ts +2 -0
  6. package/{lib → src}/graphql_fetch.d.ts +6 -4
  7. package/src/graphql_fetch.js +12 -0
  8. package/src/graphql_fetch_.d.ts +7 -0
  9. package/src/graphql_fetch_.js +29 -0
  10. package/src/graphql_port_txt_.d.ts +2 -0
  11. package/src/{graphql_port_txt_.ts → graphql_port_txt_.js} +1 -4
  12. package/src/graphql_url_.d.ts +2 -0
  13. package/src/{graphql_url_.ts → graphql_url_.js} +2 -5
  14. package/src/index.d.ts +5 -0
  15. package/src/{index.ts → index.js} +0 -2
  16. package/lib/FetchHttpHeaders.d.ts +0 -3
  17. package/lib/FetchHttpHeaders.js +0 -3
  18. package/lib/FetchHttpHeaders.js.map +0 -1
  19. package/lib/FetchHttpOpts.d.ts +0 -5
  20. package/lib/FetchHttpOpts.js +0 -3
  21. package/lib/FetchHttpOpts.js.map +0 -1
  22. package/lib/graphql_fetch.js +0 -14
  23. package/lib/graphql_fetch.js.map +0 -1
  24. package/lib/graphql_fetch_.d.ts +0 -4
  25. package/lib/graphql_fetch_.js +0 -31
  26. package/lib/graphql_fetch_.js.map +0 -1
  27. package/lib/graphql_port_txt_.d.ts +0 -2
  28. package/lib/graphql_port_txt_.js +0 -6
  29. package/lib/graphql_port_txt_.js.map +0 -1
  30. package/lib/graphql_url_.d.ts +0 -2
  31. package/lib/graphql_url_.js +0 -10
  32. package/lib/graphql_url_.js.map +0 -1
  33. package/lib/index.d.ts +0 -6
  34. package/lib/index.js +0 -8
  35. package/lib/index.js.map +0 -1
  36. package/src/FetchHttpOpts.ts +0 -5
  37. package/src/graphql_fetch.ts +0 -22
  38. package/src/graphql_fetch_.ts +0 -40
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @ctx-core/graphql-client
2
2
 
3
+ ## 7.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - update dependencies
8
+
9
+ ## 7.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - update dependencies
14
+
15
+ ## 7.1.0
16
+
17
+ ### Minor Changes
18
+
19
+ - @ctx-core/fetch-undici instead of @ctx-core/fetch
20
+
21
+ ## 7.0.124
22
+
23
+ ### Patch Changes
24
+
25
+ - .js + .d.ts instead of .ts
26
+
3
27
  ## 7.0.123
4
28
 
5
29
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctx-core/graphql-client",
3
- "version": "7.0.123",
3
+ "version": "7.1.2",
4
4
  "description": "ctx-core graphql-client",
5
5
  "keywords": [
6
6
  "ctx-core",
@@ -17,40 +17,40 @@
17
17
  "license": "Apache-2.0",
18
18
  "author": "Brian Takita",
19
19
  "type": "module",
20
- "types": "./lib/index.d.ts",
20
+ "types": "./src/index.d.ts",
21
21
  "exports": {
22
22
  ".": {
23
- "import": "./lib/index.js"
23
+ "import": "./src/index.js"
24
24
  },
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
28
  "@ctx-core/dom": "^11.1.5",
29
- "@ctx-core/fetch": "^11.0.113",
30
- "@ctx-core/object": "^22.0.12"
29
+ "@ctx-core/fetch-undici": "^1.0.3",
30
+ "@ctx-core/graphql": "^9.0.55",
31
+ "@ctx-core/object": "^22.0.13"
31
32
  },
32
33
  "devDependencies": {
33
- "@swc/cli": "^0.1.55",
34
- "@swc/core": "^1.2.133",
35
34
  "@types/node": "^17.0.10",
36
- "rimraf": "^3.0.2",
37
- "typescript": "next"
35
+ "c8": "^7.11.0",
36
+ "check-dts": "^0.6.6",
37
+ "tsm": "^2.2.1",
38
+ "typescript": "next",
39
+ "uvu": "^0.5.3"
38
40
  },
39
41
  "publishConfig": {
40
42
  "access": "public",
41
43
  "cache": "~/.npm"
42
44
  },
43
- "svelte": "./lib/index.js",
45
+ "svelte": "./src/index.js",
44
46
  "sideEffects": false,
45
47
  "scripts": {
46
- "@ctx-core/graphql": "workspace:^9.0.30",
47
- "build": "npm run compile",
48
- "clean": "rimraf lib && npm run clean:tsbuildinfo",
49
- "clean:tsbuildinfo": "rimraf tsconfig.tsbuildinfo && rimraf lib/**/*.d.ts",
50
- "compile": "npm run compile:source && npm run compile:declaration",
51
- "compile:source": "swc src --out-dir lib --copy-files --source-maps --config-file .swcrc",
52
- "compile:declaration": "npm run clean:tsbuildinfo && tsc --declaration --emitDeclarationOnly --declarationDir lib",
53
- "exec": "$@"
48
+ "build": ":",
49
+ "clean": ":",
50
+ "exec": "$@",
51
+ "test": "pnpm test-unit && check-dts",
52
+ "test-unit": "tsm node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
53
+ "test-unit-coverage": "c8 pnpm test-unit"
54
54
  },
55
55
  "readme": "# @ctx-core/graphql-client\n\nGraphQL client logic\n"
56
56
  }
@@ -1,3 +1,3 @@
1
1
  export interface FetchHttpHeaders extends Record<string, string> {
2
- 'Content-Type':string
2
+ 'Content-Type':string;
3
3
  }
@@ -0,0 +1,5 @@
1
+ import type { FetchHttpHeaders } from './FetchHttpHeaders'
2
+ export interface FetchHttpOpts {
3
+ url?:string;
4
+ headers?:FetchHttpHeaders;
5
+ }
@@ -0,0 +1,2 @@
1
+ export * from './FetchHttpHeaders'
2
+ export * from './FetchHttpOpts'
@@ -1,6 +1,8 @@
1
- import type { FetchHttpOpts } from './FetchHttpOpts.js';
2
- export declare function graphql_fetch<data_T extends unknown = unknown>(body: string, fn_in_http_opts?: FetchHttpOpts): Promise<graphql_fetch_response_T<data_T>>;
1
+ import type { FetchHttpOpts } from './_types'
2
+ export declare function graphql_fetch<data_T extends unknown = unknown>(
3
+ body:string, fn_in_http_opts?:FetchHttpOpts
4
+ ):Promise<graphql_fetch_response_T<data_T>>;
3
5
  export interface graphql_fetch_response_T<data_T extends unknown = unknown> {
4
- data: data_T;
6
+ data:data_T;
5
7
  }
6
- export { graphql_fetch as fetch_graphql, graphql_fetch as fetch__graphql, };
8
+ export { graphql_fetch as fetch_graphql, graphql_fetch as fetch__graphql, }
@@ -0,0 +1,12 @@
1
+ import { graphql_fetch_ } from './graphql_fetch_.js'
2
+ import { graphql_url_ } from './graphql_url_.js'
3
+ let in_graphql_fetch
4
+ export function graphql_fetch(body, fn_in_http_opts = {}) {
5
+ if (!in_graphql_fetch) {
6
+ in_graphql_fetch = graphql_fetch_({
7
+ url: graphql_url_()
8
+ })
9
+ }
10
+ return in_graphql_fetch(body, fn_in_http_opts)
11
+ }
12
+ export { graphql_fetch as fetch_graphql, graphql_fetch as fetch__graphql, }
@@ -0,0 +1,7 @@
1
+ import type { FetchHttpOpts } from './_types'
2
+ export declare function graphql_fetch_<O1 extends unknown = unknown>(
3
+ in_http_opts?:FetchHttpOpts
4
+ ):graphql_fetch_T<O1>;
5
+ export declare type graphql_fetch_T<O extends unknown = unknown> =
6
+ (body:string, fn_in_http_opts:FetchHttpOpts)=>Promise<O>;
7
+ export { graphql_fetch_ as _graphql_fetch, graphql_fetch_ as _fetch__graphql, }
@@ -0,0 +1,29 @@
1
+ import { safe_fetch as fetch } from '@ctx-core/fetch-undici'
2
+ import { assign } from '@ctx-core/object'
3
+ export function graphql_fetch_(in_http_opts = {}) {
4
+ return async function graphql_fetch(body, fn_in_http_opts = {}) {
5
+ const url = fn_in_http_opts.url || in_http_opts.url
6
+ if (!url) {
7
+ throw `no url prop`
8
+ }
9
+ const response = await fetch(url, assign({
10
+ method: 'POST',
11
+ headers: assign({
12
+ 'Content-Type': 'application/json'
13
+ }, in_http_opts.headers, fn_in_http_opts.headers),
14
+ body
15
+ }, in_http_opts, fn_in_http_opts))
16
+ if (!response.ok) {
17
+ if (process.env.NODE_ENV === 'production') {
18
+ console.error(await response.text())
19
+ throw `Error fetching graphql`
20
+ } else {
21
+ throw await response.text()
22
+ }
23
+ }
24
+ const payload = await response.json()
25
+ if (payload.errors) throw payload
26
+ return payload
27
+ }
28
+ }
29
+ export { graphql_fetch_ as _graphql_fetch, graphql_fetch_ as _fetch__graphql, }
@@ -0,0 +1,2 @@
1
+ export declare function graphql_port_txt_(port?:string|undefined):string;
2
+ export { graphql_port_txt_ as _graphql_port_txt, graphql_port_txt_ as _txt__port__graphql, }
@@ -1,7 +1,4 @@
1
1
  export function graphql_port_txt_(port = process.env.PORT) {
2
2
  return (port || 80) === 80 ? '' : `:${port}`
3
3
  }
4
- export {
5
- graphql_port_txt_ as _graphql_port_txt,
6
- graphql_port_txt_ as _txt__port__graphql,
7
- }
4
+ export { graphql_port_txt_ as _graphql_port_txt, graphql_port_txt_ as _txt__port__graphql, }
@@ -0,0 +1,2 @@
1
+ export declare function graphql_url_(host?:string):string;
2
+ export { graphql_url_ as _graphql_url, graphql_url_ as _url__graphql, }
@@ -1,11 +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'):string {
3
+ export function graphql_url_(host = '127.0.0.1') {
4
4
  if (has_dom) return '/graphql'
5
5
  const host_port = `${host}${graphql_port_txt_()}`
6
6
  return `http://${host_port}/graphql`
7
7
  }
8
- export {
9
- graphql_url_ as _graphql_url,
10
- graphql_url_ as _url__graphql,
11
- }
8
+ export { graphql_url_ as _graphql_url, graphql_url_ as _url__graphql, }
package/src/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './_types'
2
+ export * from './graphql_fetch_'
3
+ export * from './graphql_port_txt_'
4
+ export * from './graphql_url_'
5
+ export * from './graphql_fetch'
@@ -1,6 +1,4 @@
1
1
  export * from './graphql_fetch_.js'
2
2
  export * from './graphql_port_txt_.js'
3
3
  export * from './graphql_url_.js'
4
- export * from './FetchHttpHeaders.js'
5
- export * from './FetchHttpOpts.js'
6
4
  export * from './graphql_fetch.js'
@@ -1,3 +0,0 @@
1
- export interface FetchHttpHeaders extends Record<string, string> {
2
- 'Content-Type': string;
3
- }
@@ -1,3 +0,0 @@
1
- export { };
2
-
3
- //# sourceMappingURL=FetchHttpHeaders.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/FetchHttpHeaders.ts"],"sourcesContent":["export interface FetchHttpHeaders extends Record<string, string> {\n\t'Content-Type':string\n}\n"],"names":[],"mappings":"AAAA,MAAM"}
@@ -1,5 +0,0 @@
1
- import type { FetchHttpHeaders } from './FetchHttpHeaders.js';
2
- export interface FetchHttpOpts {
3
- url?: string;
4
- headers?: FetchHttpHeaders;
5
- }
@@ -1,3 +0,0 @@
1
- export { };
2
-
3
- //# sourceMappingURL=FetchHttpOpts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/FetchHttpOpts.ts"],"sourcesContent":["import type { FetchHttpHeaders } from './FetchHttpHeaders.js'\nexport interface FetchHttpOpts {\n\turl?:string\n\theaders?:FetchHttpHeaders,\n}\n"],"names":[],"mappings":"AAAA,MAAM"}
@@ -1,14 +0,0 @@
1
- import { graphql_fetch_ } from './graphql_fetch_.js';
2
- import { graphql_url_ } from './graphql_url_.js';
3
- let in_graphql_fetch;
4
- export function graphql_fetch(body, fn_in_http_opts = {}) {
5
- if (!in_graphql_fetch) {
6
- in_graphql_fetch = graphql_fetch_({
7
- url: graphql_url_()
8
- });
9
- }
10
- return in_graphql_fetch(body, fn_in_http_opts);
11
- }
12
- export { graphql_fetch as fetch_graphql, graphql_fetch as fetch__graphql, };
13
-
14
- //# sourceMappingURL=graphql_fetch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/graphql_fetch.ts"],"sourcesContent":["import { graphql_fetch_, graphql_fetch_T } from './graphql_fetch_.js'\nimport { graphql_url_ } from './graphql_url_.js'\nimport type { FetchHttpOpts } from './FetchHttpOpts.js'\nlet in_graphql_fetch: graphql_fetch_T\nexport function graphql_fetch<data_T extends unknown = unknown>(\n\tbody:string,\n\tfn_in_http_opts:FetchHttpOpts = {},\n):Promise<graphql_fetch_response_T<data_T>> {\n\tif (!in_graphql_fetch) {\n\t\tin_graphql_fetch = graphql_fetch_<data_T>({\n\t\t\turl: graphql_url_(),\n\t\t})\n\t}\n\treturn in_graphql_fetch(body, fn_in_http_opts) as Promise<graphql_fetch_response_T<data_T>>\n}\nexport interface graphql_fetch_response_T<data_T extends unknown = unknown> {\n\tdata: data_T\n}\nexport {\n\tgraphql_fetch as fetch_graphql,\n\tgraphql_fetch as fetch__graphql,\n}\n"],"names":["graphql_fetch_","graphql_url_","in_graphql_fetch","graphql_fetch","body","fn_in_http_opts","url","fetch_graphql","fetch__graphql"],"mappings":"AAAA,MAAM,GAAGA,cAAc,QAAyB,CAAqB;AACrE,MAAM,GAAGC,YAAY,QAAQ,CAAmB;AAEhD,GAAG,CAACC,gBAAgB;AACpB,MAAM,UAAUC,aAAa,CAC5BC,IAAW,EACXC,eAA6B,GAAG,CAAC,CAAC,EACS,CAAC;IAC5C,EAAE,GAAGH,gBAAgB,EAAE,CAAC;QACvBA,gBAAgB,GAAGF,cAAc,CAAS,CAAC;YAC1CM,GAAG,EAAEL,YAAY;QAClB,CAAC;IACF,CAAC;IACD,MAAM,CAACC,gBAAgB,CAACE,IAAI,EAAEC,eAAe;AAC9C,CAAC;AAID,MAAM,GACLF,aAAa,IAAII,aAAa,EAC9BJ,aAAa,IAAIK,cAAc"}
@@ -1,4 +0,0 @@
1
- import type { FetchHttpOpts } from './FetchHttpOpts.js';
2
- export declare function graphql_fetch_<O1 extends unknown = unknown>(in_http_opts?: FetchHttpOpts): graphql_fetch_T<O1>;
3
- export declare type graphql_fetch_T<O extends unknown = unknown> = (body: string, fn_in_http_opts: FetchHttpOpts) => Promise<O>;
4
- export { graphql_fetch_ as _graphql_fetch, graphql_fetch_ as _fetch__graphql, };
@@ -1,31 +0,0 @@
1
- import { fetch } from '@ctx-core/fetch';
2
- import { assign } from '@ctx-core/object';
3
- export function graphql_fetch_(in_http_opts = {}) {
4
- return async function graphql_fetch(body, fn_in_http_opts = {}) {
5
- const url = fn_in_http_opts.url || in_http_opts.url;
6
- if (!url) {
7
- throw `no url prop`;
8
- }
9
- const response = await fetch(url, assign({
10
- method: 'POST',
11
- headers: assign({
12
- 'Content-Type': 'application/json'
13
- }, in_http_opts.headers, fn_in_http_opts.headers),
14
- body
15
- }, in_http_opts, fn_in_http_opts));
16
- if (!response.ok) {
17
- if (process.env.NODE_ENV === 'production') {
18
- console.error(await response.text());
19
- throw `Error fetching graphql`;
20
- } else {
21
- throw await response.text();
22
- }
23
- }
24
- const payload = await response.json();
25
- if (payload.errors) throw payload;
26
- return payload;
27
- };
28
- }
29
- export { graphql_fetch_ as _graphql_fetch, graphql_fetch_ as _fetch__graphql, };
30
-
31
- //# sourceMappingURL=graphql_fetch_.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/graphql_fetch_.ts"],"sourcesContent":["import { fetch } from '@ctx-core/fetch'\nimport { assign } from '@ctx-core/object'\nimport type { FetchHttpOpts } from './FetchHttpOpts.js'\nexport function graphql_fetch_<O1 extends unknown = unknown>(\n\tin_http_opts = {} as FetchHttpOpts\n):graphql_fetch_T<O1> {\n\treturn async function graphql_fetch<O2 extends unknown = O1>(\n\t\tbody:string,\n\t\tfn_in_http_opts:FetchHttpOpts = {},\n\t):Promise<O2> {\n\t\tconst url = fn_in_http_opts.url || in_http_opts.url\n\t\tif (!url) {\n\t\t\tthrow `no url prop`\n\t\t}\n\t\tconst response = await fetch(url, assign({\n\t\t\tmethod: 'POST',\n\t\t\theaders: assign({\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t}, in_http_opts.headers, fn_in_http_opts.headers),\n\t\t\tbody,\n\t\t}, in_http_opts, fn_in_http_opts))\n\t\tif (!response.ok) {\n\t\t\tif (process.env.NODE_ENV === 'production') {\n\t\t\t\tconsole.error(await response.text())\n\t\t\t\tthrow `Error fetching graphql`\n\t\t\t} else {\n\t\t\t\tthrow (await response.text())\n\t\t\t}\n\t\t}\n\t\tconst payload = await response.json()\n\t\tif (payload.errors) throw payload\n\t\treturn payload as O2\n\t}\n}\nexport type graphql_fetch_T<O extends unknown = unknown> =\n\t(body:string, fn_in_http_opts:FetchHttpOpts)=>Promise<O>\nexport {\n\tgraphql_fetch_ as _graphql_fetch,\n\tgraphql_fetch_ as _fetch__graphql,\n}\n"],"names":["fetch","assign","graphql_fetch_","in_http_opts","graphql_fetch","body","fn_in_http_opts","url","response","method","headers","ok","process","env","NODE_ENV","console","error","text","payload","json","errors","_graphql_fetch","_fetch__graphql"],"mappings":"AAAA,MAAM,GAAGA,KAAK,QAAQ,CAAiB;AACvC,MAAM,GAAGC,MAAM,QAAQ,CAAkB;AAEzC,MAAM,UAAUC,cAAc,CAC7BC,YAAY,GAAG,CAAC,CAAC,EACI,CAAC;IACtB,MAAM,gBAAgBC,aAAa,CAClCC,IAAW,EACXC,eAA6B,GAAG,CAAC,CAAC,EACrB,CAAC;QACd,KAAK,CAACC,GAAG,GAAGD,eAAe,CAACC,GAAG,IAAIJ,YAAY,CAACI,GAAG;QACnD,EAAE,GAAGA,GAAG,EAAE,CAAC;YACV,KAAK,EAAE,WAAW;QACnB,CAAC;QACD,KAAK,CAACC,QAAQ,GAAG,KAAK,CAACR,KAAK,CAACO,GAAG,EAAEN,MAAM,CAAC,CAAC;YACzCQ,MAAM,EAAE,CAAM;YACdC,OAAO,EAAET,MAAM,CAAC,CAAC;gBAChB,CAAc,eAAE,CAAkB;YACnC,CAAC,EAAEE,YAAY,CAACO,OAAO,EAAEJ,eAAe,CAACI,OAAO;YAChDL,IAAI;QACL,CAAC,EAAEF,YAAY,EAAEG,eAAe;QAChC,EAAE,GAAGE,QAAQ,CAACG,EAAE,EAAE,CAAC;YAClB,EAAE,EAAEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,CAAY,aAAE,CAAC;gBAC3CC,OAAO,CAACC,KAAK,CAAC,KAAK,CAACR,QAAQ,CAACS,IAAI;gBACjC,KAAK,EAAE,sBAAsB;YAC9B,CAAC,MAAM,CAAC;gBACP,KAAK,CAAE,KAAK,CAACT,QAAQ,CAACS,IAAI;YAC3B,CAAC;QACF,CAAC;QACD,KAAK,CAACC,OAAO,GAAG,KAAK,CAACV,QAAQ,CAACW,IAAI;QACnC,EAAE,EAAED,OAAO,CAACE,MAAM,EAAE,KAAK,CAACF,OAAO;QACjC,MAAM,CAACA,OAAO;IACf,CAAC;AACF,CAAC;AAGD,MAAM,GACLhB,cAAc,IAAImB,cAAc,EAChCnB,cAAc,IAAIoB,eAAe"}
@@ -1,2 +0,0 @@
1
- export declare function graphql_port_txt_(port?: string | undefined): string;
2
- export { graphql_port_txt_ as _graphql_port_txt, graphql_port_txt_ as _txt__port__graphql, };
@@ -1,6 +0,0 @@
1
- export function graphql_port_txt_(port = process.env.PORT) {
2
- return (port || 80) === 80 ? '' : `:${port}`;
3
- }
4
- export { graphql_port_txt_ as _graphql_port_txt, graphql_port_txt_ as _txt__port__graphql, };
5
-
6
- //# sourceMappingURL=graphql_port_txt_.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/graphql_port_txt_.ts"],"sourcesContent":["export function graphql_port_txt_(port = process.env.PORT) {\n\treturn (port || 80) === 80 ? '' : `:${port}`\n}\nexport {\n\tgraphql_port_txt_ as _graphql_port_txt,\n\tgraphql_port_txt_ as _txt__port__graphql,\n}\n"],"names":["graphql_port_txt_","port","process","env","PORT","_graphql_port_txt","_txt__port__graphql"],"mappings":"AAAA,MAAM,UAAUA,iBAAiB,CAACC,IAAI,GAAGC,OAAO,CAACC,GAAG,CAACC,IAAI,EAAE,CAAC;IAC3D,MAAM,EAAEH,IAAI,IAAI,EAAE,MAAM,EAAE,GAAG,CAAE,KAAI,CAAC,EAAEA,IAAI;AAC3C,CAAC;AACD,MAAM,GACLD,iBAAiB,IAAIK,iBAAiB,EACtCL,iBAAiB,IAAIM,mBAAmB"}
@@ -1,2 +0,0 @@
1
- export declare function graphql_url_(host?: string): string;
2
- export { graphql_url_ as _graphql_url, graphql_url_ as _url__graphql, };
@@ -1,10 +0,0 @@
1
- import { has_dom } from '@ctx-core/dom';
2
- import { graphql_port_txt_ } from './graphql_port_txt_.js';
3
- export function graphql_url_(host = '127.0.0.1') {
4
- if (has_dom) return '/graphql';
5
- const host_port = `${host}${graphql_port_txt_()}`;
6
- return `http://${host_port}/graphql`;
7
- }
8
- export { graphql_url_ as _graphql_url, graphql_url_ as _url__graphql, };
9
-
10
- //# sourceMappingURL=graphql_url_.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/graphql_url_.ts"],"sourcesContent":["import { has_dom } from '@ctx-core/dom'\nimport { graphql_port_txt_ } from './graphql_port_txt_.js'\nexport function graphql_url_(host = '127.0.0.1'):string {\n\tif (has_dom) return '/graphql'\n\tconst host_port = `${host}${graphql_port_txt_()}`\n\treturn `http://${host_port}/graphql`\n}\nexport {\n\tgraphql_url_ as _graphql_url,\n\tgraphql_url_ as _url__graphql,\n}\n"],"names":["has_dom","graphql_port_txt_","graphql_url_","host","host_port","_graphql_url","_url__graphql"],"mappings":"AAAA,MAAM,GAAGA,OAAO,QAAQ,CAAe;AACvC,MAAM,GAAGC,iBAAiB,QAAQ,CAAwB;AAC1D,MAAM,UAAUC,YAAY,CAACC,IAAI,GAAG,CAAW,YAAS,CAAC;IACxD,EAAE,EAAEH,OAAO,EAAE,MAAM,CAAC,CAAU;IAC9B,KAAK,CAACI,SAAS,MAAMD,IAAI,GAAGF,iBAAiB;IAC7C,MAAM,EAAE,OAAO,EAAEG,SAAS,CAAC,QAAQ;AACpC,CAAC;AACD,MAAM,GACLF,YAAY,IAAIG,YAAY,EAC5BH,YAAY,IAAII,aAAa"}
package/lib/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './graphql_fetch_.js';
2
- export * from './graphql_port_txt_.js';
3
- export * from './graphql_url_.js';
4
- export * from './FetchHttpHeaders.js';
5
- export * from './FetchHttpOpts.js';
6
- export * from './graphql_fetch.js';
package/lib/index.js DELETED
@@ -1,8 +0,0 @@
1
- export * from './graphql_fetch_.js';
2
- export * from './graphql_port_txt_.js';
3
- export * from './graphql_url_.js';
4
- export * from './FetchHttpHeaders.js';
5
- export * from './FetchHttpOpts.js';
6
- export * from './graphql_fetch.js';
7
-
8
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './graphql_fetch_.js'\nexport * from './graphql_port_txt_.js'\nexport * from './graphql_url_.js'\nexport * from './FetchHttpHeaders.js'\nexport * from './FetchHttpOpts.js'\nexport * from './graphql_fetch.js'\n"],"names":[],"mappings":"cAAc,CAAqB;cACrB,CAAwB;cACxB,CAAmB;cACnB,CAAuB;cACvB,CAAoB;cACpB,CAAoB"}
@@ -1,5 +0,0 @@
1
- import type { FetchHttpHeaders } from './FetchHttpHeaders.js'
2
- export interface FetchHttpOpts {
3
- url?:string
4
- headers?:FetchHttpHeaders,
5
- }
@@ -1,22 +0,0 @@
1
- import { graphql_fetch_, graphql_fetch_T } from './graphql_fetch_.js'
2
- import { graphql_url_ } from './graphql_url_.js'
3
- import type { FetchHttpOpts } from './FetchHttpOpts.js'
4
- let in_graphql_fetch: graphql_fetch_T
5
- export function graphql_fetch<data_T extends unknown = unknown>(
6
- body:string,
7
- fn_in_http_opts:FetchHttpOpts = {},
8
- ):Promise<graphql_fetch_response_T<data_T>> {
9
- if (!in_graphql_fetch) {
10
- in_graphql_fetch = graphql_fetch_<data_T>({
11
- url: graphql_url_(),
12
- })
13
- }
14
- return in_graphql_fetch(body, fn_in_http_opts) as Promise<graphql_fetch_response_T<data_T>>
15
- }
16
- export interface graphql_fetch_response_T<data_T extends unknown = unknown> {
17
- data: data_T
18
- }
19
- export {
20
- graphql_fetch as fetch_graphql,
21
- graphql_fetch as fetch__graphql,
22
- }
@@ -1,40 +0,0 @@
1
- import { fetch } from '@ctx-core/fetch'
2
- import { assign } from '@ctx-core/object'
3
- import type { FetchHttpOpts } from './FetchHttpOpts.js'
4
- export function graphql_fetch_<O1 extends unknown = unknown>(
5
- in_http_opts = {} as FetchHttpOpts
6
- ):graphql_fetch_T<O1> {
7
- return async function graphql_fetch<O2 extends unknown = O1>(
8
- body:string,
9
- fn_in_http_opts:FetchHttpOpts = {},
10
- ):Promise<O2> {
11
- const url = fn_in_http_opts.url || in_http_opts.url
12
- if (!url) {
13
- throw `no url prop`
14
- }
15
- const response = await fetch(url, assign({
16
- method: 'POST',
17
- headers: assign({
18
- 'Content-Type': 'application/json',
19
- }, in_http_opts.headers, fn_in_http_opts.headers),
20
- body,
21
- }, in_http_opts, fn_in_http_opts))
22
- if (!response.ok) {
23
- if (process.env.NODE_ENV === 'production') {
24
- console.error(await response.text())
25
- throw `Error fetching graphql`
26
- } else {
27
- throw (await response.text())
28
- }
29
- }
30
- const payload = await response.json()
31
- if (payload.errors) throw payload
32
- return payload as O2
33
- }
34
- }
35
- export type graphql_fetch_T<O extends unknown = unknown> =
36
- (body:string, fn_in_http_opts:FetchHttpOpts)=>Promise<O>
37
- export {
38
- graphql_fetch_ as _graphql_fetch,
39
- graphql_fetch_ as _fetch__graphql,
40
- }