New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-hooks

Package Overview
Dependencies
Maintainers
12
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-hooks - npm Package Compare versions

Comparing version 4.4.3 to 4.4.4

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

## [4.4.4](https://github.com/nearform/graphql-hooks/compare/graphql-hooks@4.4.3...graphql-hooks@4.4.4) (2020-04-02)
### Bug Fixes
* **deps:** update dependency extract-files to v8 ([#481](https://github.com/nearform/graphql-hooks/issues/481)) ([b58c51a](https://github.com/nearform/graphql-hooks/commit/b58c51a3590a2960fb0270b88150c73d2f2abc23))
* clear errors on refetch via loading action ([#469](https://github.com/nearform/graphql-hooks/issues/469)) ([1caece3](https://github.com/nearform/graphql-hooks/commit/1caece33d5aabdf320433263d0a95f23a212e559))
## [4.4.3](https://github.com/nearform/graphql-hooks/compare/graphql-hooks@4.4.2...graphql-hooks@4.4.3) (2020-02-25)

@@ -8,0 +20,0 @@

25

dist/graphql-hooks.js

@@ -78,3 +78,3 @@ (function (global, factory) {

function extractFiles(value, path, isExtractableFile$1) {
var extractFiles = function extractFiles(value, path, isExtractableFile$1) {
if (path === void 0) {

@@ -103,3 +103,3 @@ path = '';

if (typeof FileList !== 'undefined' && value instanceof FileList)
clone = Array.prototype.map.call(value, function(file, i) {
clone = Array.prototype.map.call(value, function (file, i) {
addFile(['' + prefix + i], file);

@@ -109,3 +109,3 @@ return null

else if (Array.isArray(value))
clone = value.map(function(child, i) {
clone = value.map(function (child, i) {
var result = extractFiles(child, '' + prefix + i, isExtractableFile$1);

@@ -128,5 +128,5 @@ result.files.forEach(addFile);

clone: clone,
files: files
files: files,
}
}
};

@@ -139,5 +139,3 @@ var isExtractableFileEnhanced = function isExtractableFileEnhanced(value) {

var GraphQLClient =
/*#__PURE__*/
function () {
var GraphQLClient = /*#__PURE__*/function () {
function GraphQLClient(config) {

@@ -448,2 +446,10 @@ if (config === void 0) {

case actionTypes.LOADING:
// if the previous action resulted in an error - refetch should clear any errors
if (state.error) {
return _objectSpread2({}, action.initialState, {
data: state.data,
loading: true
});
}
if (state.loading) {

@@ -586,3 +592,4 @@ return state; // saves a render cycle as state is the same

dispatch({
type: actionTypes.LOADING
type: actionTypes.LOADING,
initialState: initialState
});

@@ -589,0 +596,0 @@ return client.request(revisedOperation, revisedOpts).then(function (result) {

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).GraphQLHooks={},e.React)}(this,(function(e,t){"use strict";var r="default"in t?t.default:t;function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var a=r.createContext();a.displayName="ClientContext";var s=function(e){var t=e.name,r=e.type;this.uri=e.uri,this.name=t,this.type=r},u=function(e){return"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob||e instanceof s};var c=function(e){return u(e)||null!==e&&"object"==typeof e&&"function"==typeof e.pipe},f=function(){function e(e){if(void 0===e&&(e={}),!e.url)throw Error("GraphQLClient: config.url is required");if(e.fetch&&"function"!=typeof e.fetch)throw Error("GraphQLClient: config.fetch must be a function");if(!e.fetch&&!fetch)throw Error("GraphQLClient: fetch must be polyfilled or passed in new GraphQLClient({ fetch })");if(e.ssrMode&&!e.cache)throw Error("GraphQLClient: config.cache is required when in ssrMode");this.cache=e.cache,this.headers=e.headers||{},this.ssrMode=e.ssrMode,this.ssrPromises=[],this.url=e.url,this.fetch=e.fetch||fetch.bind(),this.fetchOptions=e.fetchOptions||{},this.FormData=e.FormData||("undefined"!=typeof FormData?FormData:void 0),this.logErrors=void 0===e.logErrors||e.logErrors,this.onError=e.onError,this.useGETForQueries=!0===e.useGETForQueries,this.subscriptionClient=e.subscriptionClient}var t=e.prototype;return t.setHeader=function(e,t){return this.headers[e]=t,this},t.setHeaders=function(e){return this.headers=e,this},t.removeHeader=function(e){return delete this.headers[e],this},t.logErrorResult=function(e){var t=e.result,r=e.operation;console.error("GraphQL Hooks Error"),console.groupCollapsed("---\x3e Full Error Details"),console.groupCollapsed("Operation:"),console.log(r),console.groupEnd();var n=t.error;n&&(n.fetchError&&(console.groupCollapsed("FETCH ERROR:"),console.log(n.fetchError),console.groupEnd()),n.httpError&&(console.groupCollapsed("HTTP ERROR:"),console.log(n.httpError),console.groupEnd()),n.graphQLErrors&&n.graphQLErrors.length>0&&(console.groupCollapsed("GRAPHQL ERROR:"),n.graphQLErrors.forEach((function(e){return console.log(e)})),console.groupEnd())),console.groupEnd()},t.generateResult=function(e){var t=e.fetchError,r=e.httpError,n=e.graphQLErrors,o=e.data;return!!(n&&n.length>0||t||r)?{data:o,error:{fetchError:t,httpError:r,graphQLErrors:n}}:{data:o}},t.getCacheKey=function(e,t){return void 0===t&&(t={}),{operation:e,fetchOptions:i({},this.fetchOptions,{},t.fetchOptionsOverrides)}},t.getCache=function(e){var t=this.cache?this.cache.get(e):null;if(t)return t},t.saveCache=function(e,t){this.cache&&this.cache.set(e,t)},t.getFetchOptions=function(e,t){void 0===t&&(t={});var r=i({method:"POST",headers:i({},this.headers)},this.fetchOptions,{},t);if("GET"===r.method)return r;var n=function e(t,r,n){var o;void 0===r&&(r=""),void 0===n&&(n=u);var i=new Map;function a(e,t){var r=i.get(t);r?r.push.apply(r,e):i.set(t,e)}if(n(t))o=null,a([r],t);else{var s=r?r+".":"";if("undefined"!=typeof FileList&&t instanceof FileList)o=Array.prototype.map.call(t,(function(e,t){return a([""+s+t],e),null}));else if(Array.isArray(t))o=t.map((function(t,r){var o=e(t,""+s+r,n);return o.files.forEach(a),o.clone}));else if(t&&t.constructor===Object)for(var c in o={},t){var f=e(t[c],""+s+c,n);f.files.forEach(a),o[c]=f.clone}else o=t}return{clone:o,files:i}}(e,"",c),o=n.files,a=JSON.stringify(n.clone);if(o.size){if(!this.FormData)throw Error("GraphQLClient: FormData must be polyfilled or passed in new GraphQLClient({ FormData })");var s=new this.FormData;s.append("operations",a);var f={},l=0;o.forEach((function(e){f[++l]=e})),s.append("map",JSON.stringify(f)),l=0,o.forEach((function(e,t){s.append(""+ ++l,t,t.name)})),r.body=s}else r.headers["Content-Type"]="application/json",r.body=a;return r},t.request=function(e,t){var r=this;void 0===t&&(t={});var n=this.url;"GET"===this.getFetchOptions(e,t.fetchOptionsOverrides).method&&(n=n+"?"+Object.entries(e).filter((function(e){return!!e[1]})).map((function(e){var t=e[0],r=e[1];return"variables"===t&&(r=JSON.stringify(r)),t+"="+encodeURIComponent(r)})).join("&"));return this.fetch(n,this.getFetchOptions(e,t.fetchOptionsOverrides)).then((function(e){return e.ok?e.json().then((function(e){return r.generateResult({graphQLErrors:e.errors,data:e.data})})):e.text().then((function(t){return r.generateResult({httpError:{status:e.status,statusText:e.statusText,body:t}})}))})).catch((function(e){return r.generateResult({fetchError:e})})).then((function(t){return t.error&&(r.logErrors&&r.logErrorResult({result:t,operation:e}),r.onError&&r.onError({result:t,operation:e})),t}))},t.createSubscription=function(e){if(!this.subscriptionClient)throw Error("No SubscriptionClient! Please set in the constructor.");return this.subscriptionClient.request(e)},e}();var l="RESET_STATE",h="LOADING",p="CACHE_HIT",d="REQUEST_RESULT";function g(e,t){switch(t.type){case l:return t.initialState;case h:return e.loading?e:i({},e,{loading:!0});case p:return e.cacheHit&&!t.resetState?e:i({},t.result,{cacheHit:!0,loading:!1});case d:return i({},t.result,{data:e.data&&t.result.data&&t.updateData?t.updateData(e.data,t.result.data):t.result.data,cacheHit:!1,loading:!1});default:return e}}function v(e,t){var n=r.useRef();return function e(t,r){var n,o;if(t===r)return!0;if(t&&r&&(n=t.constructor)===r.constructor){if(n===Date)return t.getTime()===r.getTime();if(n===RegExp)return""+t==""+r;if(n===Array&&(o=t.length)===r.length){for(;o--&&e(t[o],r[o]););return-1===o}if(n===Object){if(Object.keys(t).length!==Object.keys(r).length)return!1;for(o in t)if(!(o in r&&e(t[o],r[o])))return!1;return!0}}return t!=t&&r!=r}(t,n.current)||(n.current=t),r.useCallback(e,n.current)}function E(e,t){if(void 0===t&&(t={}),"string"!=typeof e)throw Error("Your query must be a string. If you are using the `gql` template literal from graphql-tag, remove it from your query.");var n=r.useContext(a),o=t.client||n,s=r.useRef(!0),u=r.useRef(null),c={query:e,variables:t.variables,operationName:t.operationName};o.useGETForQueries&&!t.isMutation&&(t.fetchOptionsOverrides=i({},t.fetchOptionsOverrides,{method:"GET"}));var f=o.getCacheKey(c,t),E=t.isMutation||t.isManual,y=t.skipCache||!o.cache?null:o.cache.get(f),b=i({},y,{cacheHit:!!y,loading:!E&&!y}),O=r.useReducer(g,b),C=O[0],m=O[1],R=JSON.stringify(f);r.useEffect((function(){t.updateData||m({type:l,initialState:b})}),[R]),r.useEffect((function(){return s.current=!0,function(){s.current=!1}}),[]);var D=v((function(e){if(!s.current)return Promise.resolve();var r=i({},t,{},e),n=i({},c,{variables:r.variables,operationName:r.operationName}),a=o.getCacheKey(n,r);u.current=a;var f=r.skipCache?null:o.getCache(a);return f?(m({type:p,result:f,resetState:R!==JSON.stringify(C.cacheKey)}),Promise.resolve(f)):(m({type:h}),o.request(n,r).then((function(e){if(r.updateData&&"function"!=typeof r.updateData)throw Error("options.updateData must be a function");var t=i({},e);if(r.useCache&&(t.useCache=!0,t.cacheKey=a,o.ssrMode)){var n={data:r.updateData?r.updateData(C.data,t.data):t.data};o.saveCache(a,n)}return s.current&&a===u.current&&m({type:d,updateData:r.updateData,result:t}),e})))}),[o,t,c]);return r.useEffect((function(){C.useCache&&o.saveCache(C.cacheKey,C)}),[o,C]),[D,C]}var y={useCache:!0};e.ClientContext=a,e.GraphQLClient=f,e.useClientRequest=E,e.useManualQuery=function(e,t){return E(e,i({useCache:!0,isManual:!0},t))},e.useMutation=function(e,t){return E(e,i({isMutation:!0},t))},e.useQuery=function(e,t){void 0===t&&(t={});var n=i({},y,{},t),o=r.useContext(a),s=t.client||o,u=r.useState(!1),c=u[0],f=u[1],l=E(e,n),h=l[0],p=l[1];if(s.ssrMode&&!1!==t.ssr&&!c&&!t.skipCache){if(!p.data&&!p.error){var d=h();s.ssrPromises.push(d)}f(!0)}var g=JSON.stringify(n);return r.useEffect((function(){h()}),[e,g]),i({},p,{refetch:r.useCallback((function(e){return void 0===e&&(e={}),h(i({skipCache:!0,updateData:function(e,t){return t}},e))}),[h])})},e.useSubscription=function(e,r){var n=t.useRef(r);n.current=r;var o=t.useContext(a),i=e.client||o,s={query:e.query,variables:e.variables};t.useEffect((function(){var e=i.createSubscription(s).subscribe({next:function(e){n.current(e)},error:function(){e.unsubscribe()},complete:function(){e.unsubscribe()}});return function(){e.unsubscribe()}}),[])},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).GraphQLHooks={},e.React)}(this,(function(e,t){"use strict";var r="default"in t?t.default:t;function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var a=r.createContext();a.displayName="ClientContext";var s=function(e){var t=e.name,r=e.type;this.uri=e.uri,this.name=t,this.type=r},u=function(e){return"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob||e instanceof s},c=function(e){return u(e)||null!==e&&"object"==typeof e&&"function"==typeof e.pipe},f=function(){function e(e){if(void 0===e&&(e={}),!e.url)throw Error("GraphQLClient: config.url is required");if(e.fetch&&"function"!=typeof e.fetch)throw Error("GraphQLClient: config.fetch must be a function");if(!e.fetch&&!fetch)throw Error("GraphQLClient: fetch must be polyfilled or passed in new GraphQLClient({ fetch })");if(e.ssrMode&&!e.cache)throw Error("GraphQLClient: config.cache is required when in ssrMode");this.cache=e.cache,this.headers=e.headers||{},this.ssrMode=e.ssrMode,this.ssrPromises=[],this.url=e.url,this.fetch=e.fetch||fetch.bind(),this.fetchOptions=e.fetchOptions||{},this.FormData=e.FormData||("undefined"!=typeof FormData?FormData:void 0),this.logErrors=void 0===e.logErrors||e.logErrors,this.onError=e.onError,this.useGETForQueries=!0===e.useGETForQueries,this.subscriptionClient=e.subscriptionClient}var t=e.prototype;return t.setHeader=function(e,t){return this.headers[e]=t,this},t.setHeaders=function(e){return this.headers=e,this},t.removeHeader=function(e){return delete this.headers[e],this},t.logErrorResult=function(e){var t=e.result,r=e.operation;console.error("GraphQL Hooks Error"),console.groupCollapsed("---\x3e Full Error Details"),console.groupCollapsed("Operation:"),console.log(r),console.groupEnd();var n=t.error;n&&(n.fetchError&&(console.groupCollapsed("FETCH ERROR:"),console.log(n.fetchError),console.groupEnd()),n.httpError&&(console.groupCollapsed("HTTP ERROR:"),console.log(n.httpError),console.groupEnd()),n.graphQLErrors&&n.graphQLErrors.length>0&&(console.groupCollapsed("GRAPHQL ERROR:"),n.graphQLErrors.forEach((function(e){return console.log(e)})),console.groupEnd())),console.groupEnd()},t.generateResult=function(e){var t=e.fetchError,r=e.httpError,n=e.graphQLErrors,o=e.data;return!!(n&&n.length>0||t||r)?{data:o,error:{fetchError:t,httpError:r,graphQLErrors:n}}:{data:o}},t.getCacheKey=function(e,t){return void 0===t&&(t={}),{operation:e,fetchOptions:i({},this.fetchOptions,{},t.fetchOptionsOverrides)}},t.getCache=function(e){var t=this.cache?this.cache.get(e):null;if(t)return t},t.saveCache=function(e,t){this.cache&&this.cache.set(e,t)},t.getFetchOptions=function(e,t){void 0===t&&(t={});var r=i({method:"POST",headers:i({},this.headers)},this.fetchOptions,{},t);if("GET"===r.method)return r;var n=function e(t,r,n){var o;void 0===r&&(r=""),void 0===n&&(n=u);var i=new Map;function a(e,t){var r=i.get(t);r?r.push.apply(r,e):i.set(t,e)}if(n(t))o=null,a([r],t);else{var s=r?r+".":"";if("undefined"!=typeof FileList&&t instanceof FileList)o=Array.prototype.map.call(t,(function(e,t){return a([""+s+t],e),null}));else if(Array.isArray(t))o=t.map((function(t,r){var o=e(t,""+s+r,n);return o.files.forEach(a),o.clone}));else if(t&&t.constructor===Object)for(var c in o={},t){var f=e(t[c],""+s+c,n);f.files.forEach(a),o[c]=f.clone}else o=t}return{clone:o,files:i}}(e,"",c),o=n.files,a=JSON.stringify(n.clone);if(o.size){if(!this.FormData)throw Error("GraphQLClient: FormData must be polyfilled or passed in new GraphQLClient({ FormData })");var s=new this.FormData;s.append("operations",a);var f={},l=0;o.forEach((function(e){f[++l]=e})),s.append("map",JSON.stringify(f)),l=0,o.forEach((function(e,t){s.append(""+ ++l,t,t.name)})),r.body=s}else r.headers["Content-Type"]="application/json",r.body=a;return r},t.request=function(e,t){var r=this;void 0===t&&(t={});var n=this.url;"GET"===this.getFetchOptions(e,t.fetchOptionsOverrides).method&&(n=n+"?"+Object.entries(e).filter((function(e){return!!e[1]})).map((function(e){var t=e[0],r=e[1];return"variables"===t&&(r=JSON.stringify(r)),t+"="+encodeURIComponent(r)})).join("&"));return this.fetch(n,this.getFetchOptions(e,t.fetchOptionsOverrides)).then((function(e){return e.ok?e.json().then((function(e){return r.generateResult({graphQLErrors:e.errors,data:e.data})})):e.text().then((function(t){return r.generateResult({httpError:{status:e.status,statusText:e.statusText,body:t}})}))})).catch((function(e){return r.generateResult({fetchError:e})})).then((function(t){return t.error&&(r.logErrors&&r.logErrorResult({result:t,operation:e}),r.onError&&r.onError({result:t,operation:e})),t}))},t.createSubscription=function(e){if(!this.subscriptionClient)throw Error("No SubscriptionClient! Please set in the constructor.");return this.subscriptionClient.request(e)},e}();var l="RESET_STATE",h="LOADING",p="CACHE_HIT",d="REQUEST_RESULT";function g(e,t){switch(t.type){case l:return t.initialState;case h:return e.error?i({},t.initialState,{data:e.data,loading:!0}):e.loading?e:i({},e,{loading:!0});case p:return e.cacheHit&&!t.resetState?e:i({},t.result,{cacheHit:!0,loading:!1});case d:return i({},t.result,{data:e.data&&t.result.data&&t.updateData?t.updateData(e.data,t.result.data):t.result.data,cacheHit:!1,loading:!1});default:return e}}function v(e,t){var n=r.useRef();return function e(t,r){var n,o;if(t===r)return!0;if(t&&r&&(n=t.constructor)===r.constructor){if(n===Date)return t.getTime()===r.getTime();if(n===RegExp)return""+t==""+r;if(n===Array&&(o=t.length)===r.length){for(;o--&&e(t[o],r[o]););return-1===o}if(n===Object){if(Object.keys(t).length!==Object.keys(r).length)return!1;for(o in t)if(!(o in r)||!e(t[o],r[o]))return!1;return!0}}return t!=t&&r!=r}(t,n.current)||(n.current=t),r.useCallback(e,n.current)}function E(e,t){if(void 0===t&&(t={}),"string"!=typeof e)throw Error("Your query must be a string. If you are using the `gql` template literal from graphql-tag, remove it from your query.");var n=r.useContext(a),o=t.client||n,s=r.useRef(!0),u=r.useRef(null),c={query:e,variables:t.variables,operationName:t.operationName};o.useGETForQueries&&!t.isMutation&&(t.fetchOptionsOverrides=i({},t.fetchOptionsOverrides,{method:"GET"}));var f=o.getCacheKey(c,t),E=t.isMutation||t.isManual,y=t.skipCache||!o.cache?null:o.cache.get(f),b=i({},y,{cacheHit:!!y,loading:!E&&!y}),O=r.useReducer(g,b),C=O[0],m=O[1],R=JSON.stringify(f);r.useEffect((function(){t.updateData||m({type:l,initialState:b})}),[R]),r.useEffect((function(){return s.current=!0,function(){s.current=!1}}),[]);var D=v((function(e){if(!s.current)return Promise.resolve();var r=i({},t,{},e),n=i({},c,{variables:r.variables,operationName:r.operationName}),a=o.getCacheKey(n,r);u.current=a;var f=r.skipCache?null:o.getCache(a);return f?(m({type:p,result:f,resetState:R!==JSON.stringify(C.cacheKey)}),Promise.resolve(f)):(m({type:h,initialState:b}),o.request(n,r).then((function(e){if(r.updateData&&"function"!=typeof r.updateData)throw Error("options.updateData must be a function");var t=i({},e);if(r.useCache&&(t.useCache=!0,t.cacheKey=a,o.ssrMode)){var n={data:r.updateData?r.updateData(C.data,t.data):t.data};o.saveCache(a,n)}return s.current&&a===u.current&&m({type:d,updateData:r.updateData,result:t}),e})))}),[o,t,c]);return r.useEffect((function(){C.useCache&&o.saveCache(C.cacheKey,C)}),[o,C]),[D,C]}var y={useCache:!0};e.ClientContext=a,e.GraphQLClient=f,e.useClientRequest=E,e.useManualQuery=function(e,t){return E(e,i({useCache:!0,isManual:!0},t))},e.useMutation=function(e,t){return E(e,i({isMutation:!0},t))},e.useQuery=function(e,t){void 0===t&&(t={});var n=i({},y,{},t),o=r.useContext(a),s=t.client||o,u=r.useState(!1),c=u[0],f=u[1],l=E(e,n),h=l[0],p=l[1];if(s.ssrMode&&!1!==t.ssr&&!c&&!t.skipCache){if(!p.data&&!p.error){var d=h();s.ssrPromises.push(d)}f(!0)}var g=JSON.stringify(n);return r.useEffect((function(){h()}),[e,g]),i({},p,{refetch:r.useCallback((function(e){return void 0===e&&(e={}),h(i({skipCache:!0,updateData:function(e,t){return t}},e))}),[h])})},e.useSubscription=function(e,r){var n=t.useRef(r);n.current=r;var o=t.useContext(a),i=e.client||o,s={query:e.query,variables:e.variables};t.useEffect((function(){var e=i.createSubscription(s).subscribe({next:function(e){n.current(e)},error:function(){e.unsubscribe()},complete:function(){e.unsubscribe()}});return function(){e.unsubscribe()}}),[])},Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -63,5 +63,3 @@ import React, { useRef, useContext, useEffect } from 'react';

var GraphQLClient =
/*#__PURE__*/
function () {
var GraphQLClient = /*#__PURE__*/function () {
function GraphQLClient(config) {

@@ -353,2 +351,10 @@ if (config === void 0) {

case actionTypes.LOADING:
// if the previous action resulted in an error - refetch should clear any errors
if (state.error) {
return _objectSpread2({}, action.initialState, {
data: state.data,
loading: true
});
}
if (state.loading) {

@@ -491,3 +497,4 @@ return state; // saves a render cycle as state is the same

dispatch({
type: actionTypes.LOADING
type: actionTypes.LOADING,
initialState: initialState
});

@@ -494,0 +501,0 @@ return client.request(revisedOperation, revisedOpts).then(function (result) {

@@ -70,5 +70,3 @@ 'use strict';

var GraphQLClient =
/*#__PURE__*/
function () {
var GraphQLClient = /*#__PURE__*/function () {
function GraphQLClient(config) {

@@ -360,2 +358,10 @@ if (config === void 0) {

case actionTypes.LOADING:
// if the previous action resulted in an error - refetch should clear any errors
if (state.error) {
return _objectSpread2({}, action.initialState, {
data: state.data,
loading: true
});
}
if (state.loading) {

@@ -498,3 +504,4 @@ return state; // saves a render cycle as state is the same

dispatch({
type: actionTypes.LOADING
type: actionTypes.LOADING,
initialState: initialState
});

@@ -501,0 +508,0 @@ return client.request(revisedOperation, revisedOpts).then(function (result) {

{
"name": "graphql-hooks",
"version": "4.4.3",
"version": "4.4.4",
"description": "Graphql Hooks",

@@ -38,9 +38,9 @@ "main": "lib/graphql-hooks.js",

"dequal": "^1.0.0",
"extract-files": "^7.0.0"
"extract-files": "^8.0.0"
},
"devDependencies": {
"@testing-library/react": "^9.3.2",
"@testing-library/react": "^10.0.0",
"@testing-library/react-hooks": "^3.2.1",
"formdata-node": "^2.0.0",
"graphql-hooks-memcache": "^1.3.1",
"graphql-hooks-memcache": "^1.3.2",
"graphql-hooks-ssr": "^1.1.5",

@@ -62,3 +62,3 @@ "jest-fetch-mock": "^3.0.0",

"homepage": "https://github.com/nearform/graphql-hooks#readme",
"gitHead": "66034955b289022f1f124c19c5d52d53b15d1209"
"gitHead": "348b10cad7a42959a76c1d976fa6343a2253cb25"
}

@@ -17,2 +17,10 @@ import React from 'react'

case actionTypes.LOADING:
// if the previous action resulted in an error - refetch should clear any errors
if (state.error) {
return {
...action.initialState,
data: state.data,
loading: true
}
}
if (state.loading) {

@@ -158,3 +166,3 @@ return state // saves a render cycle as state is the same

dispatch({ type: actionTypes.LOADING })
dispatch({ type: actionTypes.LOADING, initialState })
return client.request(revisedOperation, revisedOpts).then(result => {

@@ -161,0 +169,0 @@ if (

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc