graphql-http 1.11.0 → 1.13.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/lib/utils.d.mts CHANGED
@@ -3,7 +3,8 @@
3
3
  * utils
4
4
  *
5
5
  */
6
- import type { ExecutionResult, GraphQLError } from 'graphql';
6
+ import type { ExecutionResult } from 'graphql';
7
+ import { GraphQLError } from 'graphql';
7
8
  /** @private */
8
9
  export declare function extendedTypeof(val: unknown): 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'array' | 'null';
9
10
  /** @private */
@@ -11,6 +12,8 @@ export declare function isObject(val: unknown): val is Record<PropertyKey, any>;
11
12
  /** @private */
12
13
  export declare function areGraphQLErrors(obj: unknown): obj is readonly GraphQLError[];
13
14
  /** @private */
15
+ export declare function isGraphQLError(obj: unknown): obj is GraphQLError;
16
+ /** @private */
14
17
  export declare function isExecutionResult(val: unknown): val is ExecutionResult;
15
18
  /** @private */
16
19
  export declare function isAsyncIterable<T = unknown>(val: unknown): val is AsyncIterable<T>;
package/lib/utils.d.ts CHANGED
@@ -3,7 +3,8 @@
3
3
  * utils
4
4
  *
5
5
  */
6
- import type { ExecutionResult, GraphQLError } from 'graphql';
6
+ import type { ExecutionResult } from 'graphql';
7
+ import { GraphQLError } from 'graphql';
7
8
  /** @private */
8
9
  export declare function extendedTypeof(val: unknown): 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'array' | 'null';
9
10
  /** @private */
@@ -11,6 +12,8 @@ export declare function isObject(val: unknown): val is Record<PropertyKey, any>;
11
12
  /** @private */
12
13
  export declare function areGraphQLErrors(obj: unknown): obj is readonly GraphQLError[];
13
14
  /** @private */
15
+ export declare function isGraphQLError(obj: unknown): obj is GraphQLError;
16
+ /** @private */
14
17
  export declare function isExecutionResult(val: unknown): val is ExecutionResult;
15
18
  /** @private */
16
19
  export declare function isAsyncIterable<T = unknown>(val: unknown): val is AsyncIterable<T>;
package/lib/utils.js CHANGED
@@ -5,7 +5,8 @@
5
5
  *
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.isAsyncIterable = exports.isExecutionResult = exports.areGraphQLErrors = exports.isObject = exports.extendedTypeof = void 0;
8
+ exports.isAsyncIterable = exports.isExecutionResult = exports.isGraphQLError = exports.areGraphQLErrors = exports.isObject = exports.extendedTypeof = void 0;
9
+ const graphql_1 = require("graphql");
9
10
  /** @private */
10
11
  function extendedTypeof(val) {
11
12
  if (val === null) {
@@ -25,13 +26,17 @@ exports.isObject = isObject;
25
26
  /** @private */
26
27
  function areGraphQLErrors(obj) {
27
28
  return (Array.isArray(obj) &&
28
- // must be at least one error
29
29
  obj.length > 0 &&
30
- // error has at least a message
31
- obj.every((ob) => 'message' in ob));
30
+ // if one item in the array is a GraphQLError, we're good
31
+ obj.some(isGraphQLError));
32
32
  }
33
33
  exports.areGraphQLErrors = areGraphQLErrors;
34
34
  /** @private */
35
+ function isGraphQLError(obj) {
36
+ return obj instanceof graphql_1.GraphQLError;
37
+ }
38
+ exports.isGraphQLError = isGraphQLError;
39
+ /** @private */
35
40
  function isExecutionResult(val) {
36
41
  return (isObject(val) &&
37
42
  ('data' in val || ('data' in val && val.data == null && 'errors' in val)));
package/lib/utils.mjs CHANGED
@@ -3,6 +3,7 @@
3
3
  * utils
4
4
  *
5
5
  */
6
+ import { GraphQLError } from 'graphql';
6
7
  /** @private */
7
8
  export function extendedTypeof(val) {
8
9
  if (val === null) {
@@ -20,10 +21,13 @@ export function isObject(val) {
20
21
  /** @private */
21
22
  export function areGraphQLErrors(obj) {
22
23
  return (Array.isArray(obj) &&
23
- // must be at least one error
24
24
  obj.length > 0 &&
25
- // error has at least a message
26
- obj.every((ob) => 'message' in ob));
25
+ // if one item in the array is a GraphQLError, we're good
26
+ obj.some(isGraphQLError));
27
+ }
28
+ /** @private */
29
+ export function isGraphQLError(obj) {
30
+ return obj instanceof GraphQLError;
27
31
  }
28
32
  /** @private */
29
33
  export function isExecutionResult(val) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-http",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "Simple, pluggable, zero-dependency, GraphQL over HTTP Protocol compliant server and client",
5
5
  "keywords": [
6
6
  "graphql",
@@ -95,42 +95,42 @@
95
95
  "graphql": ">=0.11 <=16"
96
96
  },
97
97
  "devDependencies": {
98
- "@babel/core": "^7.20.7",
98
+ "@babel/core": "^7.20.12",
99
99
  "@babel/plugin-proposal-class-properties": "^7.18.6",
100
100
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
101
101
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
102
102
  "@babel/plugin-proposal-optional-chaining": "^7.20.7",
103
103
  "@babel/preset-env": "^7.20.2",
104
104
  "@babel/preset-typescript": "^7.18.6",
105
- "@rollup/plugin-terser": "^0.2.1",
106
- "@rollup/plugin-typescript": "^10.0.1",
105
+ "@rollup/plugin-terser": "^0.4.0",
106
+ "@rollup/plugin-typescript": "^11.0.0",
107
107
  "@semantic-release/changelog": "^6.0.2",
108
108
  "@semantic-release/git": "^10.0.1",
109
109
  "@types/eslint": "^8.4.10",
110
- "@types/express": "^4.17.15",
111
- "@types/glob": "^8.0.0",
112
- "@types/jest": "^29.2.4",
110
+ "@types/express": "^4.17.16",
111
+ "@types/glob": "^8.0.1",
112
+ "@types/jest": "^29.4.0",
113
113
  "@types/koa": "^2.13.5",
114
114
  "@types/koa-mount": "^4.0.2",
115
- "@typescript-eslint/eslint-plugin": "^5.47.0",
116
- "@typescript-eslint/parser": "^5.47.0",
117
- "@whatwg-node/fetch": "^0.5.3",
118
- "babel-jest": "^29.3.1",
119
- "eslint": "^8.30.0",
120
- "eslint-config-prettier": "^8.5.0",
115
+ "@typescript-eslint/eslint-plugin": "^5.49.0",
116
+ "@typescript-eslint/parser": "^5.49.0",
117
+ "@whatwg-node/fetch": "^0.6.2",
118
+ "babel-jest": "^29.4.0",
119
+ "eslint": "^8.32.0",
120
+ "eslint-config-prettier": "^8.6.0",
121
121
  "express": "^4.18.2",
122
- "fastify": "^4.10.2",
122
+ "fastify": "^4.12.0",
123
123
  "graphql": "^16.6.0",
124
- "jest": "^29.3.1",
125
- "jest-jasmine2": "^29.3.1",
124
+ "jest": "^29.4.0",
125
+ "jest-jasmine2": "^29.4.0",
126
126
  "koa": "^2.14.1",
127
127
  "koa-mount": "^4.0.0",
128
128
  "node-fetch": "^3.3.0",
129
- "prettier": "^2.8.1",
130
- "rollup": "^3.8.1",
131
- "semantic-release": "^19.0.5",
129
+ "prettier": "^2.8.3",
130
+ "rollup": "^3.11.0",
131
+ "semantic-release": "^20.1.0",
132
132
  "tslib": "^2.4.1",
133
- "typedoc": "^0.23.23",
133
+ "typedoc": "^0.23.24",
134
134
  "typedoc-plugin-markdown": "^3.14.0",
135
135
  "typescript": "^4.9.4"
136
136
  },
@@ -1,6 +1,6 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('graphql')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'graphql'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.graphqlHttp = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).graphqlHttp={})}(this,(function(e){"use strict";class t extends Error{constructor(e){let t,r;var o;(function(e){return"object"==typeof e&&null!==e})(o=e)&&"boolean"==typeof o.ok&&"number"==typeof o.status&&"string"==typeof o.statusText?(r=e,t="Server responded with "+e.status+": "+e.statusText):t=e instanceof Error?e.message:String(e),super(t),this.name=this.constructor.name,this.response=r}}e.NetworkError=t,e.createClient=function(e){const{credentials:r="same-origin",referrer:o,referrerPolicy:n,shouldRetry:s=(()=>!1)}=e,i=e.fetchFn||fetch,a=e.abortControllerImpl||AbortController,c=(()=>{let e=!1;const t=[];return{get disposed(){return e},onDispose:r=>e?(setTimeout((()=>r()),0),()=>{}):(t.push(r),()=>{t.splice(t.indexOf(r),1)}),dispose(){if(!e){e=!0;for(const e of[...t])e()}}}})();return{subscribe(p,l){if(c.disposed)throw new Error("Client has been disposed");const f=new a,u=c.onDispose((()=>{u(),f.abort()}));return(async()=>{var a;let c=null,u=0;for(;;){if(c){const e=await s(c,u);if(f.signal.aborted)return;if(!e)throw c;u++}try{const s="function"==typeof e.url?await e.url(p):e.url;if(f.signal.aborted)return;const c="function"==typeof e.headers?await e.headers():null!==(a=e.headers)&&void 0!==a?a:{};if(f.signal.aborted)return;let u;try{u=await i(s,{signal:f.signal,method:"POST",headers:Object.assign(Object.assign({},c),{"content-type":"application/json; charset=utf-8",accept:"application/graphql-response+json, application/json"}),credentials:r,referrer:o,referrerPolicy:n,body:JSON.stringify(p)})}catch(e){throw new t(e)}if(!u.ok)throw new t(u);if(!u.body)throw new Error("Missing response body");const d=u.headers.get("content-type");if(!d)throw new Error("Missing response content-type");if(!d.includes("application/graphql-response+json")&&!d.includes("application/json"))throw new Error(`Unsupported response content-type ${d}`);const h=await u.json();return l.next(h),f.abort()}catch(e){if(f.signal.aborted)return;if(!(e instanceof t))throw e;c=e}}})().then((()=>l.complete())).catch((e=>l.error(e))),()=>f.abort()},dispose(){c.dispose()}}}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("graphql")):"function"==typeof define&&define.amd?define(["exports","graphql"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).graphqlHttp={})}(this,(function(e){"use strict";class t extends Error{constructor(e){let t,r;var o;(function(e){return"object"==typeof e&&null!==e})(o=e)&&"boolean"==typeof o.ok&&"number"==typeof o.status&&"string"==typeof o.statusText?(r=e,t="Server responded with "+e.status+": "+e.statusText):t=e instanceof Error?e.message:String(e),super(t),this.name=this.constructor.name,this.response=r}}e.NetworkError=t,e.createClient=function(e){const{credentials:r="same-origin",referrer:o,referrerPolicy:n,shouldRetry:s=(()=>!1)}=e,i=e.fetchFn||fetch,a=e.abortControllerImpl||AbortController,c=(()=>{let e=!1;const t=[];return{get disposed(){return e},onDispose:r=>e?(setTimeout((()=>r()),0),()=>{}):(t.push(r),()=>{t.splice(t.indexOf(r),1)}),dispose(){if(!e){e=!0;for(const e of[...t])e()}}}})();return{subscribe(p,l){if(c.disposed)throw new Error("Client has been disposed");const f=new a,u=c.onDispose((()=>{u(),f.abort()}));return(async()=>{var a;let c=null,u=0;for(;;){if(c){const e=await s(c,u);if(f.signal.aborted)return;if(!e)throw c;u++}try{const s="function"==typeof e.url?await e.url(p):e.url;if(f.signal.aborted)return;const c="function"==typeof e.headers?await e.headers():null!==(a=e.headers)&&void 0!==a?a:{};if(f.signal.aborted)return;let u;try{u=await i(s,{signal:f.signal,method:"POST",headers:Object.assign(Object.assign({},c),{"content-type":"application/json; charset=utf-8",accept:"application/graphql-response+json, application/json"}),credentials:r,referrer:o,referrerPolicy:n,body:JSON.stringify(p)})}catch(e){throw new t(e)}if(!u.ok)throw new t(u);if(!u.body)throw new Error("Missing response body");const d=u.headers.get("content-type");if(!d)throw new Error("Missing response content-type");if(!d.includes("application/graphql-response+json")&&!d.includes("application/json"))throw new Error(`Unsupported response content-type ${d}`);const h=await u.json();return l.next(h),f.abort()}catch(e){if(f.signal.aborted)return;if(!(e instanceof t))throw e;c=e}}})().then((()=>l.complete())).catch((e=>l.error(e))),()=>f.abort()},dispose(){c.dispose()}}}}));
Binary file