graphql-http
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -108,3 +108,3 @@ "use strict"; | ||
method: 'POST', | ||
headers: Object.assign(Object.assign({}, headers), { 'content-type': 'application/json; charset=utf-8', accept: 'application/graphql+json, application/json' }), | ||
headers: Object.assign(Object.assign({}, headers), { 'content-type': 'application/json; charset=utf-8', accept: 'application/graphql-response+json, application/json' }), | ||
credentials, | ||
@@ -126,3 +126,3 @@ referrer, | ||
throw new Error('Missing response content-type'); | ||
if (!contentType.includes('application/graphql+json') && | ||
if (!contentType.includes('application/graphql-response+json') && | ||
!contentType.includes('application/json')) { | ||
@@ -129,0 +129,0 @@ throw new Error(`Unsupported response content-type ${contentType}`); |
@@ -261,3 +261,3 @@ /** | ||
*/ | ||
export declare type AcceptableMediaType = 'application/graphql+json' | 'application/json'; | ||
export declare type AcceptableMediaType = 'application/graphql-response+json' | 'application/json'; | ||
/** | ||
@@ -264,0 +264,0 @@ * Inspects the request and detects the appropriate/acceptable Media-Type |
@@ -103,3 +103,3 @@ "use strict"; | ||
headers: { | ||
accept: 'application/graphql+json; charset=utf-8, application/json; charset=utf-8', | ||
accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8', | ||
}, | ||
@@ -295,7 +295,7 @@ }, | ||
} | ||
if ((mediaType === 'application/graphql+json' || | ||
if ((mediaType === 'application/graphql-response+json' || | ||
mediaType === 'application/*' || | ||
mediaType === '*/*') && | ||
charset === 'charset=utf8') { | ||
acceptedMediaType = 'application/graphql+json'; | ||
acceptedMediaType = 'application/graphql-response+json'; | ||
break; | ||
@@ -327,3 +327,3 @@ } | ||
? 'application/json; charset=utf-8' | ||
: 'application/graphql+json; charset=utf-8', | ||
: 'application/graphql-response+json; charset=utf-8', | ||
}, | ||
@@ -352,3 +352,3 @@ }, | ||
? 'application/json; charset=utf-8' | ||
: 'application/graphql+json; charset=utf-8', | ||
: 'application/graphql-response+json; charset=utf-8', | ||
} }), | ||
@@ -355,0 +355,0 @@ ]; |
{ | ||
"name": "graphql-http", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Simple, pluggable, zero-dependency, GraphQL over HTTP Protocol compliant server and client", | ||
@@ -78,7 +78,7 @@ "keywords": [ | ||
"@semantic-release/git": "^10.0.1", | ||
"@types/jest": "^28.1.6", | ||
"@typescript-eslint/eslint-plugin": "^5.33.0", | ||
"@typescript-eslint/parser": "^5.33.0", | ||
"@types/jest": "^28.1.7", | ||
"@typescript-eslint/eslint-plugin": "^5.33.1", | ||
"@typescript-eslint/parser": "^5.33.1", | ||
"babel-jest": "^28.1.3", | ||
"eslint": "^8.21.0", | ||
"eslint": "^8.22.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
@@ -92,3 +92,3 @@ "eslint-plugin-prettier": "^4.2.1", | ||
"replacestream": "^4.0.3", | ||
"rollup": "^2.77.3", | ||
"rollup": "^2.78.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
@@ -95,0 +95,0 @@ "semantic-release": "^19.0.3", |
@@ -104,3 +104,3 @@ (function (global, factory) { | ||
method: 'POST', | ||
headers: Object.assign(Object.assign({}, headers), { 'content-type': 'application/json; charset=utf-8', accept: 'application/graphql+json, application/json' }), | ||
headers: Object.assign(Object.assign({}, headers), { 'content-type': 'application/json; charset=utf-8', accept: 'application/graphql-response+json, application/json' }), | ||
credentials, | ||
@@ -122,3 +122,3 @@ referrer, | ||
throw new Error('Missing response content-type'); | ||
if (!contentType.includes('application/graphql+json') && | ||
if (!contentType.includes('application/graphql-response+json') && | ||
!contentType.includes('application/json')) { | ||
@@ -125,0 +125,0 @@ throw new Error(`Unsupported response content-type ${contentType}`); |
@@ -1,1 +0,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(l,p){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(l):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+json, application/json"}),credentials:r,referrer:o,referrerPolicy:n,body:JSON.stringify(l)})}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+json")&&!d.includes("application/json"))throw new Error(`Unsupported response content-type ${d}`);const h=await u.json();return p.next(h),f.abort()}catch(e){if(f.signal.aborted)return;if(!(e instanceof t))throw e;c=e}}})().then((()=>p.complete())).catch((e=>p.error(e))),()=>f.abort()},dispose(){c.dispose()}}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!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()}}},Object.defineProperty(e,"__esModule",{value:!0})})); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
99018