From 6753471a345a7725adb29c2f0d5bfbfd554ee30b Mon Sep 17 00:00:00 2001 From: Kennet Postigo Date: Fri, 20 May 2016 09:12:45 -0400 Subject: [PATCH] updated params, removed queryParams by mistake. --- dist/react-reach.js | 5 +++-- dist/react-reach.min.js | 2 +- package.json | 2 +- src/utils/transport.js | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dist/react-reach.js b/dist/react-reach.js index 880cc96..b7ac11a 100644 --- a/dist/react-reach.js +++ b/dist/react-reach.js @@ -98,7 +98,7 @@ return /******/ (function(modules) { // webpackBootstrap * @return {[Promise]} [Promise containing payload] */ - function transport(path, query, token) { + function transport(path, query, queryParams, token) { return (0, _isomorphicFetch2.default)(path, { method: 'POST', headers: { @@ -107,7 +107,8 @@ return /******/ (function(modules) { // webpackBootstrap 'authorization': token }, body: (0, _stringify2.default)({ - query: query + query: query, + queryParams: queryParams }) }).then(function (response) { return response.json(); diff --git a/dist/react-reach.min.js b/dist/react-reach.min.js index db52e5d..56ffbe8 100644 --- a/dist/react-reach.min.js +++ b/dist/react-reach.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["react-reach"]=e():t["react-reach"]=e()}(this,function(){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.reachWithDispatch=e.reachGraphQL=void 0;var o=r(2),n=r(3);e.reachGraphQL=o.reachGraphQL,e.reachWithDispatch=n.reachWithDispatch},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e,r){return(0,u.default)(t,{method:"POST",headers:{Accept:"application/json","content-type":"application/json",authorization:r},body:(0,s.default)({query:e})}).then(function(t){return t.json()}).then(function(t){if(t&&t.errors)throw Error(t.errors);return t.data})}Object.defineProperty(e,"__esModule",{value:!0});var i=r(4),s=o(i);e.transport=n;var a=r(7),u=o(a)},function(t,e,r){"use strict";function o(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments[3];return(0,n.transport)(t,e,r,o).then(function(t){return t})}Object.defineProperty(e,"__esModule",{value:!0}),e.reachGraphQL=o;var n=r(1)},function(t,e,r){"use strict";function o(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments[3],i=arguments[4];return(0,n.transport)(t,e,r,o).then(function(t){return function(e){return e(i(t))}})}Object.defineProperty(e,"__esModule",{value:!0}),e.reachWithDispatch=o;var n=r(1)},function(t,e,r){t.exports={"default":r(5),__esModule:!0}},function(t,e,r){var o=r(6);t.exports=function(t){return(o.JSON&&o.JSON.stringify||JSON.stringify).apply(JSON,arguments)}},function(t,e){var r=t.exports={version:"1.2.6"};"number"==typeof __e&&(__e=r)},function(t,e,r){r(8),t.exports=self.fetch.bind(self)},function(t,e){!function(t){"use strict";function e(t){if("string"!=typeof t&&(t+=""),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t+=""),t}function o(t){this.map={},t instanceof o?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function n(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function i(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function s(t){var e=new FileReader;return e.readAsArrayBuffer(t),i(e)}function a(t){var e=new FileReader;return e.readAsText(t),i(e)}function u(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(l.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(l.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(t){if(!l.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type&&this.headers.set("content-type",this._bodyBlob.type))},l.blob?(this.blob=function(){var t=n(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(s)},this.text=function(){var t=n(this);if(t)return t;if(this._bodyBlob)return a(this._bodyBlob);if(this._bodyFormData)throw Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var t=n(this);return t?t:Promise.resolve(this._bodyText)},l.formData&&(this.formData=function(){return this.text().then(d)}),this.json=function(){return this.text().then(JSON.parse)},this}function h(t){var e=t.toUpperCase();return y.indexOf(e)>-1?e:t}function f(t,e){e=e||{};var r=e.body;if(f.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new o(t.headers)),this.method=t.method,this.mode=t.mode,r||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new o(e.headers)),this.method=h(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function d(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}}),e}function c(t){var e=new o,r=t.getAllResponseHeaders().trim().split("\n");return r.forEach(function(t){var r=t.trim().split(":"),o=r.shift().trim(),n=r.join(":").trim();e.append(o,n)}),e}function p(t,e){e||(e={}),this.type="default",this.status=e.status,this.ok=this.status>=200&&300>this.status,this.statusText=e.statusText,this.headers=e.headers instanceof o?e.headers:new o(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){o.prototype.append=function(t,o){t=e(t),o=r(o);var n=this.map[t];n||(n=[],this.map[t]=n),n.push(o)},o.prototype.delete=function(t){delete this.map[e(t)]},o.prototype.get=function(t){var r=this.map[e(t)];return r?r[0]:null},o.prototype.getAll=function(t){return this.map[e(t)]||[]},o.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},o.prototype.set=function(t,o){this.map[e(t)]=[r(o)]},o.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(o){t.call(e,o,r,this)},this)},this)};var l={blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t},y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];f.prototype.clone=function(){return new f(this)},u.call(f.prototype),u.call(p.prototype),p.prototype.clone=function(){return new p(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new o(this.headers),url:this.url})},p.error=function(){var t=new p(null,{status:0,statusText:""});return t.type="error",t};var b=[301,302,303,307,308];p.redirect=function(t,e){if(-1===b.indexOf(e))throw new RangeError("Invalid status code");return new p(null,{status:e,headers:{location:t}})},t.Headers=o,t.Request=f,t.Response=p,t.fetch=function(t,e){return new Promise(function(r,o){function n(){return"responseURL"in s?s.responseURL:/^X-Request-URL:/m.test(s.getAllResponseHeaders())?s.getResponseHeader("X-Request-URL"):void 0}var i;i=f.prototype.isPrototypeOf(t)&&!e?t:new f(t,e);var s=new XMLHttpRequest;s.onload=function(){var t=1223===s.status?204:s.status;if(100>t||t>599)return void o(new TypeError("Network request failed"));var e={status:t,statusText:s.statusText,headers:c(s),url:n()},i="response"in s?s.response:s.responseText;r(new p(i,e))},s.onerror=function(){o(new TypeError("Network request failed"))},s.open(i.method,i.url,!0),"include"===i.credentials&&(s.withCredentials=!0),"responseType"in s&&l.blob&&(s.responseType="blob"),i.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["react-reach"]=e():t["react-reach"]=e()}(this,function(){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.reachWithDispatch=e.reachGraphQL=void 0;var o=r(2),n=r(3);e.reachGraphQL=o.reachGraphQL,e.reachWithDispatch=n.reachWithDispatch},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e,r,o){return(0,u.default)(t,{method:"POST",headers:{Accept:"application/json","content-type":"application/json",authorization:o},body:(0,s.default)({query:e,queryParams:r})}).then(function(t){return t.json()}).then(function(t){if(t&&t.errors)throw Error(t.errors);return t.data})}Object.defineProperty(e,"__esModule",{value:!0});var i=r(4),s=o(i);e.transport=n;var a=r(7),u=o(a)},function(t,e,r){"use strict";function o(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments[3];return(0,n.transport)(t,e,r,o).then(function(t){return t})}Object.defineProperty(e,"__esModule",{value:!0}),e.reachGraphQL=o;var n=r(1)},function(t,e,r){"use strict";function o(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments[3],i=arguments[4];return(0,n.transport)(t,e,r,o).then(function(t){return function(e){return e(i(t))}})}Object.defineProperty(e,"__esModule",{value:!0}),e.reachWithDispatch=o;var n=r(1)},function(t,e,r){t.exports={"default":r(5),__esModule:!0}},function(t,e,r){var o=r(6);t.exports=function(t){return(o.JSON&&o.JSON.stringify||JSON.stringify).apply(JSON,arguments)}},function(t,e){var r=t.exports={version:"1.2.6"};"number"==typeof __e&&(__e=r)},function(t,e,r){r(8),t.exports=self.fetch.bind(self)},function(t,e){!function(t){"use strict";function e(t){if("string"!=typeof t&&(t+=""),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t+=""),t}function o(t){this.map={},t instanceof o?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function n(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function i(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function s(t){var e=new FileReader;return e.readAsArrayBuffer(t),i(e)}function a(t){var e=new FileReader;return e.readAsText(t),i(e)}function u(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(l.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(l.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(t){if(!l.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type&&this.headers.set("content-type",this._bodyBlob.type))},l.blob?(this.blob=function(){var t=n(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(s)},this.text=function(){var t=n(this);if(t)return t;if(this._bodyBlob)return a(this._bodyBlob);if(this._bodyFormData)throw Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var t=n(this);return t?t:Promise.resolve(this._bodyText)},l.formData&&(this.formData=function(){return this.text().then(d)}),this.json=function(){return this.text().then(JSON.parse)},this}function h(t){var e=t.toUpperCase();return y.indexOf(e)>-1?e:t}function f(t,e){e=e||{};var r=e.body;if(f.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new o(t.headers)),this.method=t.method,this.mode=t.mode,r||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new o(e.headers)),this.method=h(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function d(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}}),e}function c(t){var e=new o,r=t.getAllResponseHeaders().trim().split("\n");return r.forEach(function(t){var r=t.trim().split(":"),o=r.shift().trim(),n=r.join(":").trim();e.append(o,n)}),e}function p(t,e){e||(e={}),this.type="default",this.status=e.status,this.ok=this.status>=200&&300>this.status,this.statusText=e.statusText,this.headers=e.headers instanceof o?e.headers:new o(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){o.prototype.append=function(t,o){t=e(t),o=r(o);var n=this.map[t];n||(n=[],this.map[t]=n),n.push(o)},o.prototype.delete=function(t){delete this.map[e(t)]},o.prototype.get=function(t){var r=this.map[e(t)];return r?r[0]:null},o.prototype.getAll=function(t){return this.map[e(t)]||[]},o.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},o.prototype.set=function(t,o){this.map[e(t)]=[r(o)]},o.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(o){t.call(e,o,r,this)},this)},this)};var l={blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t},y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];f.prototype.clone=function(){return new f(this)},u.call(f.prototype),u.call(p.prototype),p.prototype.clone=function(){return new p(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new o(this.headers),url:this.url})},p.error=function(){var t=new p(null,{status:0,statusText:""});return t.type="error",t};var b=[301,302,303,307,308];p.redirect=function(t,e){if(-1===b.indexOf(e))throw new RangeError("Invalid status code");return new p(null,{status:e,headers:{location:t}})},t.Headers=o,t.Request=f,t.Response=p,t.fetch=function(t,e){return new Promise(function(r,o){function n(){return"responseURL"in s?s.responseURL:/^X-Request-URL:/m.test(s.getAllResponseHeaders())?s.getResponseHeader("X-Request-URL"):void 0}var i;i=f.prototype.isPrototypeOf(t)&&!e?t:new f(t,e);var s=new XMLHttpRequest;s.onload=function(){var t=1223===s.status?204:s.status;if(100>t||t>599)return void o(new TypeError("Network request failed"));var e={status:t,statusText:s.statusText,headers:c(s),url:n()},i="response"in s?s.response:s.responseText;r(new p(i,e))},s.onerror=function(){o(new TypeError("Network request failed"))},s.open(i.method,i.url,!0),"include"===i.credentials&&(s.withCredentials=!0),"responseType"in s&&l.blob&&(s.responseType="blob"),i.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)}])}); \ No newline at end of file diff --git a/package.json b/package.json index 134c0ce..dcf7756 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-reach", - "version": "0.3.9", + "version": "0.4.0", "description": "A small library for react to communicate with GraphQL", "main": "dist/react-reach.js", "scripts": { diff --git a/src/utils/transport.js b/src/utils/transport.js index 2788ab5..94c932d 100644 --- a/src/utils/transport.js +++ b/src/utils/transport.js @@ -8,7 +8,7 @@ import fetch from 'isomorphic-fetch'; * @return {[Promise]} [Promise containing payload] */ -export function transport (path, query, token) { +export function transport (path, query, queryParams, token) { return fetch(path, { method: 'POST', headers: { @@ -17,7 +17,8 @@ export function transport (path, query, token) { 'authorization': token }, body: JSON.stringify({ - query + query, + queryParams }) }) .then((response) => {