Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-offline-hooks

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-offline-hooks - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

148

dist/apollo-offline-hooks.cjs.development.js

@@ -7,3 +7,2 @@ 'use strict';

var tslib = require('tslib');
var ApolloReactHooks = require('@apollo/react-hooks');

@@ -13,2 +12,35 @@ var apolloUtilities = require('apollo-utilities');

function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
(function (OperationTypes) {

@@ -60,5 +92,3 @@ OperationTypes["AUTO"] = "auto";

return path.reduce(function (acc, elem) {
var _a;
var val = (_a = acc) === null || _a === void 0 ? void 0 : _a[elem];
var val = acc === null || acc === void 0 ? void 0 : acc[elem];
if (val !== undefined) return val;

@@ -95,5 +125,5 @@ return null;

opName = '';
} // Note: we do a toLowerCase() and startsWith() to avoid ambiguity with operations like "RemoveAddendum"
}
// Note: we do a toLowerCase() and startsWith() to avoid ambiguity with operations like "RemoveAddendum"
var comparator = function comparator(prefix) {

@@ -105,5 +135,4 @@ return opName.toLowerCase().startsWith(prefix) || opName.toLowerCase().startsWith("on" + prefix);

[[offlineConfig.prefixesForAdd, exports.OperationTypes.ADD], [offlineConfig.prefixesForRemove, exports.OperationTypes.REMOVE], [offlineConfig.prefixesForUpdate, exports.OperationTypes.UPDATE]].forEach(function (row) {
var _a = row,
prefix = _a[0],
type = _a[1];
var prefix = row[0],
type = row[1];

@@ -118,3 +147,3 @@ if (prefix.some(comparator)) {

var updateExistingKeys = function updateExistingKeys(oldItem, newItem) {
return tslib.__assign(tslib.__assign({}, oldItem), pick(newItem, Object.keys(oldItem).filter(function (key) {
return _extends({}, oldItem, {}, pick(newItem, Object.keys(oldItem).filter(function (key) {
return key !== '__typename';

@@ -128,5 +157,5 @@ })));

if (Array.isArray(currentValue)) {
return newItem ? tslib.__spreadArrays(currentValue.filter(function (item) {
return newItem ? [].concat(currentValue.filter(function (item) {
return item[idField] !== newItem[idField];
}), [newItem]) : tslib.__spreadArrays(currentValue);
}), [newItem]) : [].concat(currentValue);
} else {

@@ -142,3 +171,3 @@ return newItem;

return item[idField] === newItem[idField] ? updateExistingKeys(item, newItem) : item;
}) : tslib.__spreadArrays(currentValue);
}) : [].concat(currentValue);
} else {

@@ -154,3 +183,3 @@ return updateExistingKeys(currentValue, newItem);

return item[idField] !== newItem[idField];
}) : tslib.__spreadArrays(currentValue);
}) : [].concat(currentValue);
} else {

@@ -170,15 +199,17 @@ return null;

};
var updateCache = function updateCache(_a) {
var client = _a.client,
data = _a.data,
idField = _a.idField,
updateQuery = _a.updateQuery,
_b = _a.operationType,
operationType = _b === void 0 ? exports.OperationTypes.AUTO : _b,
mapResultToUpdate = _a.mapResultToUpdate;
var updateCache = function updateCache(_ref) {
var _offlineConfig$getIdF;
var _c, _d;
var client = _ref.client,
data = _ref.data,
idField = _ref.idField,
updateQuery = _ref.updateQuery,
_ref$operationType = _ref.operationType,
operationType = _ref$operationType === void 0 ? exports.OperationTypes.AUTO : _ref$operationType,
mapResultToUpdate = _ref.mapResultToUpdate;
if (!data) return;
if (!data) return;
var opFieldName = Object.keys(data)[0];
var _Object$keys = Object.keys(data),
opFieldName = _Object$keys[0];
var opType = operationType === exports.OperationTypes.AUTO ? getOpTypeFromOperationName(opFieldName) : operationType;

@@ -198,3 +229,3 @@ if (!data[opFieldName]) return;

});
} catch (_e) {
} catch (_unused) {
return;

@@ -204,3 +235,3 @@ }

if (!cachedQueryResult) return;
var idFieldName = idField || ((_d = (_c = offlineConfig).getIdFieldFromObject) === null || _d === void 0 ? void 0 : _d.call(_c, mutatedItem)) || offlineConfig.idField;
var idFieldName = idField || ((_offlineConfig$getIdF = offlineConfig.getIdFieldFromObject) === null || _offlineConfig$getIdF === void 0 ? void 0 : _offlineConfig$getIdF.call(offlineConfig, mutatedItem)) || offlineConfig.idField;
var updaterFn = getUpdater(opType, idFieldName);

@@ -225,13 +256,13 @@ var updatedQueryData = produce(cachedQueryResult, function (draft) {

};
var getMutationOptions = function getMutationOptions(_a) {
var updateQuery = _a.updateQuery,
idField = _a.idField,
operationType = _a.operationType,
mapResultToUpdate = _a.mapResultToUpdate,
options = tslib.__rest(_a, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
var getMutationOptions = function getMutationOptions(_ref2) {
var updateQuery = _ref2.updateQuery,
idField = _ref2.idField,
operationType = _ref2.operationType,
mapResultToUpdate = _ref2.mapResultToUpdate,
options = _objectWithoutPropertiesLoose(_ref2, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
if (!updateQuery || options.update) return options;
return tslib.__assign({
update: function update(client, _a) {
var data = _a.data;
return _extends({
update: function update(client, _ref3) {
var data = _ref3.data;
updateCache({

@@ -248,14 +279,14 @@ client: client,

};
var getSubscriptionOptions = function getSubscriptionOptions(_a) {
var updateQuery = _a.updateQuery,
idField = _a.idField,
operationType = _a.operationType,
mapResultToUpdate = _a.mapResultToUpdate,
options = tslib.__rest(_a, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
var getSubscriptionOptions = function getSubscriptionOptions(_ref4) {
var updateQuery = _ref4.updateQuery,
idField = _ref4.idField,
operationType = _ref4.operationType,
mapResultToUpdate = _ref4.mapResultToUpdate,
options = _objectWithoutPropertiesLoose(_ref4, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
if (!updateQuery || options.onSubscriptionData) return options;
return tslib.__assign({
onSubscriptionData: function onSubscriptionData(_a) {
var client = _a.client,
data = _a.subscriptionData.data;
return _extends({
onSubscriptionData: function onSubscriptionData(_ref5) {
var client = _ref5.client,
data = _ref5.subscriptionData.data;
updateCache({

@@ -275,19 +306,16 @@ client: client,

var updateApolloCache = updateCache;
var useMutation = function useMutation(mutation, _a) {
if (_a === void 0) {
_a = {};
}
var useMutation = function useMutation(mutation, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
updateQuery = _ref.updateQuery,
idField = _ref.idField,
operationType = _ref.operationType,
mapResultToUpdate = _ref.mapResultToUpdate,
mutationHookOptions = _objectWithoutPropertiesLoose(_ref, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
var updateQuery = _a.updateQuery,
idField = _a.idField,
operationType = _a.operationType,
mapResultToUpdate = _a.mapResultToUpdate,
mutationHookOptions = tslib.__rest(_a, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
var _ApolloReactHooks$use = ApolloReactHooks.useMutation(mutation, mutationHookOptions),
mutationFunction = _ApolloReactHooks$use[0],
mutationResult = _ApolloReactHooks$use[1];
var _b = ApolloReactHooks.useMutation(mutation, mutationHookOptions),
mutationFunction = _b[0],
mutationResult = _b[1];
var enhancedMutationFunction = function enhancedMutationFunction(mutationFunctionOptions) {
return mutationFunction(getMutationOptions(tslib.__assign({
return mutationFunction(getMutationOptions(_extends({
updateQuery: updateQuery,

@@ -294,0 +322,0 @@ idField: idField,

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,r=require("tslib"),i=require("@apollo/react-hooks"),a=require("apollo-utilities"),o=(e=require("immer"))&&"object"==typeof e&&"default"in e?e.default:e;(t=exports.OperationTypes||(exports.OperationTypes={})).AUTO="auto",t.ADD="add",t.REMOVE="remove",t.UPDATE="update";var n=["delete","deleted","discard","discarded","erase","erased","remove","removed"],u=["update","updated","upsert","upserted","edit","edited","modify","modified","analyze","activate"],p=["create","created","put","set","add","added","new","insert","inserted","duplicate","import"],s=function(e){return null!=e&&"object"==typeof e},d={prefixesForRemove:n,prefixesForUpdate:u,prefixesForAdd:p,idField:"id"},c=function(e,t){return r.__assign(r.__assign({},e),(i=t,a=Object.keys(e).filter((function(e){return"__typename"!==e})),o={},i?(a.forEach((function(e){void 0!==i[e]&&(o[e]=i[e])})),o):o));var i,a,o},l=function(e){var t,i,n=e.client,u=e.data,p=e.idField,l=e.updateQuery,f=e.operationType,y=void 0===f?exports.OperationTypes.AUTO:f,v=e.mapResultToUpdate;if(u){var T=Object.keys(u)[0],m=y===exports.OperationTypes.AUTO?function(e){void 0===e&&(e="");var t=function(t){return e.toLowerCase().startsWith(t)||e.toLowerCase().startsWith("on"+t)},r=exports.OperationTypes.AUTO;return[[d.prefixesForAdd,exports.OperationTypes.ADD],[d.prefixesForRemove,exports.OperationTypes.REMOVE],[d.prefixesForUpdate,exports.OperationTypes.UPDATE]].forEach((function(e){var i=e[1];e[0].some(t)&&(r=i)})),r}(T):y;if(u[T]){var x,_=v?v(u):u[T],O=l.query||l,A=l.variables||{},F=a.resultKeyNameFromField(O.definitions[0].selectionSet.selections[0]);try{x=n.readQuery({query:O,variables:A})}catch(e){return}if(x){var b=function(e,t){switch(e){case exports.OperationTypes.ADD:return function(e,i){return Array.isArray(e)?i?r.__spreadArrays(e.filter((function(e){return e[t]!==i[t]})),[i]):r.__spreadArrays(e):i};case exports.OperationTypes.UPDATE:return function(e,i){return Array.isArray(e)?i?e.map((function(e){return e[t]===i[t]?c(e,i):e})):r.__spreadArrays(e):c(e,i)};case exports.OperationTypes.REMOVE:return function(e,i){return Array.isArray(e)?i?e.filter((function(e){return e[t]!==i[t]})):r.__spreadArrays(e):null};default:return function(e){return e}}}(m,p||(null===(i=(t=d).getIdFieldFromObject)||void 0===i?void 0:i.call(t,_))||d.idField),U=o(x,(function(e){var t=e[F],r=function e(t,r){return void 0===r&&(r=[]),Array.isArray(t)?r:s(t)?(Object.keys(t).some((function(a){var o=e(t[a],r.concat(a));return!!o&&(i=o,!0)})),i):void 0;var i}(t),i=b(function(e,t){return s(e)&&t&&0!==t.length?t.reduce((function(e,t){var r,i=null===(r=e)||void 0===r?void 0:r[t];return void 0!==i?i:null}),e):e}(t,r),_);r&&0!==r.length?function(e,t,r){void 0===t&&(t=[]),t.reduce((function(t,i,a,o){return o.length-1===a?(t[i]=r,e):t[i]}),e)}(t,r,i):e[F]=i}));n.writeQuery({query:O,variables:A,data:U})}}}},f=l;Object.keys(i).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return i[e]}})})),exports.prefixesForAdd=p,exports.prefixesForRemove=n,exports.prefixesForUpdate=u,exports.setOfflineConfig=function(e){return Object.assign(d,e)},exports.updateApolloCache=f,exports.useMutation=function(e,t){void 0===t&&(t={});var a=t.updateQuery,o=t.idField,n=t.operationType,u=t.mapResultToUpdate,p=r.__rest(t,["updateQuery","idField","operationType","mapResultToUpdate"]),s=i.useMutation(e,p),d=s[0];return[function(e){return d(function(e){var t=e.updateQuery,i=e.idField,a=e.operationType,o=e.mapResultToUpdate,n=r.__rest(e,["updateQuery","idField","operationType","mapResultToUpdate"]);return!t||n.update?n:r.__assign({update:function(e,r){l({client:e,data:r.data,idField:i,mapResultToUpdate:o,operationType:a,updateQuery:t})}},n)}(r.__assign({updateQuery:a,idField:o,operationType:n,mapResultToUpdate:u},e)))},s[1]]},exports.useSubscription=function(e,t){return void 0===t&&(t={}),i.useSubscription(e,(o=(a=t).updateQuery,n=a.idField,u=a.operationType,p=a.mapResultToUpdate,s=r.__rest(a,["updateQuery","idField","operationType","mapResultToUpdate"]),!o||s.onSubscriptionData?s:r.__assign({onSubscriptionData:function(e){l({client:e.client,data:e.subscriptionData.data,updateQuery:o,operationType:u,idField:n,mapResultToUpdate:p})}},s)));var a,o,n,u,p,s};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,r=require("@apollo/react-hooks"),o=require("apollo-utilities"),i=(e=require("immer"))&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function a(e,t){if(null==e)return{};var r,o,i={},n=Object.keys(e);for(o=0;o<n.length;o++)t.indexOf(r=n[o])>=0||(i[r]=e[r]);return i}(t=exports.OperationTypes||(exports.OperationTypes={})).AUTO="auto",t.ADD="add",t.REMOVE="remove",t.UPDATE="update";var u=["delete","deleted","discard","discarded","erase","erased","remove","removed"],p=["update","updated","upsert","upserted","edit","edited","modify","modified","analyze","activate"],d=["create","created","put","set","add","added","new","insert","inserted","duplicate","import"],s=function(e){return null!=e&&"object"==typeof e},c={prefixesForRemove:u,prefixesForUpdate:p,prefixesForAdd:d,idField:"id"},l=function(e,t){return n({},e,{},(r=t,o=Object.keys(e).filter((function(e){return"__typename"!==e})),i={},r?(o.forEach((function(e){void 0!==r[e]&&(i[e]=r[e])})),i):i));var r,o,i},f=function(e){var t,r=e.client,n=e.data,a=e.idField,u=e.updateQuery,p=e.operationType,d=void 0===p?exports.OperationTypes.AUTO:p,f=e.mapResultToUpdate;if(n){var y=Object.keys(n)[0],v=d===exports.OperationTypes.AUTO?function(e){void 0===e&&(e="");var t=function(t){return e.toLowerCase().startsWith(t)||e.toLowerCase().startsWith("on"+t)},r=exports.OperationTypes.AUTO;return[[c.prefixesForAdd,exports.OperationTypes.ADD],[c.prefixesForRemove,exports.OperationTypes.REMOVE],[c.prefixesForUpdate,exports.OperationTypes.UPDATE]].forEach((function(e){var o=e[1];e[0].some(t)&&(r=o)})),r}(y):d;if(n[y]){var T,O=f?f(n):n[y],x=u.query||u,m=u.variables||{},F=o.resultKeyNameFromField(x.definitions[0].selectionSet.selections[0]);try{T=r.readQuery({query:x,variables:m})}catch(e){return}if(T){var b=function(e,t){switch(e){case exports.OperationTypes.ADD:return function(e,r){return Array.isArray(e)?r?[].concat(e.filter((function(e){return e[t]!==r[t]})),[r]):[].concat(e):r};case exports.OperationTypes.UPDATE:return function(e,r){return Array.isArray(e)?r?e.map((function(e){return e[t]===r[t]?l(e,r):e})):[].concat(e):l(e,r)};case exports.OperationTypes.REMOVE:return function(e,r){return Array.isArray(e)?r?e.filter((function(e){return e[t]!==r[t]})):[].concat(e):null};default:return function(e){return e}}}(v,a||(null===(t=c.getIdFieldFromObject)||void 0===t?void 0:t.call(c,O))||c.idField),A=i(T,(function(e){var t=e[F],r=function e(t,r){return void 0===r&&(r=[]),Array.isArray(t)?r:s(t)?(Object.keys(t).some((function(i){var n=e(t[i],r.concat(i));return!!n&&(o=n,!0)})),o):void 0;var o}(t),o=b(function(e,t){return s(e)&&t&&0!==t.length?t.reduce((function(e,t){var r=null==e?void 0:e[t];return void 0!==r?r:null}),e):e}(t,r),O);r&&0!==r.length?function(e,t,r){void 0===t&&(t=[]),t.reduce((function(t,o,i,n){return n.length-1===i?(t[o]=r,e):t[o]}),e)}(t,r,o):e[F]=o}));r.writeQuery({query:x,variables:m,data:A})}}}},y=f;Object.keys(r).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return r[e]}})})),exports.prefixesForAdd=d,exports.prefixesForRemove=u,exports.prefixesForUpdate=p,exports.setOfflineConfig=function(e){return Object.assign(c,e)},exports.updateApolloCache=y,exports.useMutation=function(e,t){var o=void 0===t?{}:t,i=o.updateQuery,u=o.idField,p=o.operationType,d=o.mapResultToUpdate,s=a(o,["updateQuery","idField","operationType","mapResultToUpdate"]),c=r.useMutation(e,s),l=c[0];return[function(e){return l(function(e){var t=e.updateQuery,r=e.idField,o=e.operationType,i=e.mapResultToUpdate,u=a(e,["updateQuery","idField","operationType","mapResultToUpdate"]);return!t||u.update?u:n({update:function(e,n){f({client:e,data:n.data,idField:r,mapResultToUpdate:i,operationType:o,updateQuery:t})}},u)}(n({updateQuery:i,idField:u,operationType:p,mapResultToUpdate:d},e)))},c[1]]},exports.useSubscription=function(e,t){return void 0===t&&(t={}),r.useSubscription(e,(i=(o=t).updateQuery,u=o.idField,p=o.operationType,d=o.mapResultToUpdate,s=a(o,["updateQuery","idField","operationType","mapResultToUpdate"]),!i||s.onSubscriptionData?s:n({onSubscriptionData:function(e){f({client:e.client,data:e.subscriptionData.data,updateQuery:i,operationType:p,idField:u,mapResultToUpdate:d})}},s)));var o,i,u,p,d,s};
//# sourceMappingURL=apollo-offline-hooks.cjs.production.min.js.map

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

import { __rest, __assign, __spreadArrays } from 'tslib';
import { useMutation as useMutation$1, useSubscription as useSubscription$1 } from '@apollo/react-hooks';

@@ -7,2 +6,35 @@ export * from '@apollo/react-hooks';

function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
var OperationTypes;

@@ -56,5 +88,3 @@

return path.reduce(function (acc, elem) {
var _a;
var val = (_a = acc) === null || _a === void 0 ? void 0 : _a[elem];
var val = acc === null || acc === void 0 ? void 0 : acc[elem];
if (val !== undefined) return val;

@@ -91,5 +121,5 @@ return null;

opName = '';
} // Note: we do a toLowerCase() and startsWith() to avoid ambiguity with operations like "RemoveAddendum"
}
// Note: we do a toLowerCase() and startsWith() to avoid ambiguity with operations like "RemoveAddendum"
var comparator = function comparator(prefix) {

@@ -101,5 +131,4 @@ return opName.toLowerCase().startsWith(prefix) || opName.toLowerCase().startsWith("on" + prefix);

[[offlineConfig.prefixesForAdd, OperationTypes.ADD], [offlineConfig.prefixesForRemove, OperationTypes.REMOVE], [offlineConfig.prefixesForUpdate, OperationTypes.UPDATE]].forEach(function (row) {
var _a = row,
prefix = _a[0],
type = _a[1];
var prefix = row[0],
type = row[1];

@@ -114,3 +143,3 @@ if (prefix.some(comparator)) {

var updateExistingKeys = function updateExistingKeys(oldItem, newItem) {
return __assign(__assign({}, oldItem), pick(newItem, Object.keys(oldItem).filter(function (key) {
return _extends({}, oldItem, {}, pick(newItem, Object.keys(oldItem).filter(function (key) {
return key !== '__typename';

@@ -124,5 +153,5 @@ })));

if (Array.isArray(currentValue)) {
return newItem ? __spreadArrays(currentValue.filter(function (item) {
return newItem ? [].concat(currentValue.filter(function (item) {
return item[idField] !== newItem[idField];
}), [newItem]) : __spreadArrays(currentValue);
}), [newItem]) : [].concat(currentValue);
} else {

@@ -138,3 +167,3 @@ return newItem;

return item[idField] === newItem[idField] ? updateExistingKeys(item, newItem) : item;
}) : __spreadArrays(currentValue);
}) : [].concat(currentValue);
} else {

@@ -150,3 +179,3 @@ return updateExistingKeys(currentValue, newItem);

return item[idField] !== newItem[idField];
}) : __spreadArrays(currentValue);
}) : [].concat(currentValue);
} else {

@@ -166,15 +195,17 @@ return null;

};
var updateCache = function updateCache(_a) {
var client = _a.client,
data = _a.data,
idField = _a.idField,
updateQuery = _a.updateQuery,
_b = _a.operationType,
operationType = _b === void 0 ? OperationTypes.AUTO : _b,
mapResultToUpdate = _a.mapResultToUpdate;
var updateCache = function updateCache(_ref) {
var _offlineConfig$getIdF;
var _c, _d;
var client = _ref.client,
data = _ref.data,
idField = _ref.idField,
updateQuery = _ref.updateQuery,
_ref$operationType = _ref.operationType,
operationType = _ref$operationType === void 0 ? OperationTypes.AUTO : _ref$operationType,
mapResultToUpdate = _ref.mapResultToUpdate;
if (!data) return;
if (!data) return;
var opFieldName = Object.keys(data)[0];
var _Object$keys = Object.keys(data),
opFieldName = _Object$keys[0];
var opType = operationType === OperationTypes.AUTO ? getOpTypeFromOperationName(opFieldName) : operationType;

@@ -194,3 +225,3 @@ if (!data[opFieldName]) return;

});
} catch (_e) {
} catch (_unused) {
return;

@@ -200,3 +231,3 @@ }

if (!cachedQueryResult) return;
var idFieldName = idField || ((_d = (_c = offlineConfig).getIdFieldFromObject) === null || _d === void 0 ? void 0 : _d.call(_c, mutatedItem)) || offlineConfig.idField;
var idFieldName = idField || ((_offlineConfig$getIdF = offlineConfig.getIdFieldFromObject) === null || _offlineConfig$getIdF === void 0 ? void 0 : _offlineConfig$getIdF.call(offlineConfig, mutatedItem)) || offlineConfig.idField;
var updaterFn = getUpdater(opType, idFieldName);

@@ -221,13 +252,13 @@ var updatedQueryData = produce(cachedQueryResult, function (draft) {

};
var getMutationOptions = function getMutationOptions(_a) {
var updateQuery = _a.updateQuery,
idField = _a.idField,
operationType = _a.operationType,
mapResultToUpdate = _a.mapResultToUpdate,
options = __rest(_a, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
var getMutationOptions = function getMutationOptions(_ref2) {
var updateQuery = _ref2.updateQuery,
idField = _ref2.idField,
operationType = _ref2.operationType,
mapResultToUpdate = _ref2.mapResultToUpdate,
options = _objectWithoutPropertiesLoose(_ref2, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
if (!updateQuery || options.update) return options;
return __assign({
update: function update(client, _a) {
var data = _a.data;
return _extends({
update: function update(client, _ref3) {
var data = _ref3.data;
updateCache({

@@ -244,14 +275,14 @@ client: client,

};
var getSubscriptionOptions = function getSubscriptionOptions(_a) {
var updateQuery = _a.updateQuery,
idField = _a.idField,
operationType = _a.operationType,
mapResultToUpdate = _a.mapResultToUpdate,
options = __rest(_a, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
var getSubscriptionOptions = function getSubscriptionOptions(_ref4) {
var updateQuery = _ref4.updateQuery,
idField = _ref4.idField,
operationType = _ref4.operationType,
mapResultToUpdate = _ref4.mapResultToUpdate,
options = _objectWithoutPropertiesLoose(_ref4, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
if (!updateQuery || options.onSubscriptionData) return options;
return __assign({
onSubscriptionData: function onSubscriptionData(_a) {
var client = _a.client,
data = _a.subscriptionData.data;
return _extends({
onSubscriptionData: function onSubscriptionData(_ref5) {
var client = _ref5.client,
data = _ref5.subscriptionData.data;
updateCache({

@@ -271,19 +302,16 @@ client: client,

var updateApolloCache = updateCache;
var useMutation = function useMutation(mutation, _a) {
if (_a === void 0) {
_a = {};
}
var useMutation = function useMutation(mutation, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
updateQuery = _ref.updateQuery,
idField = _ref.idField,
operationType = _ref.operationType,
mapResultToUpdate = _ref.mapResultToUpdate,
mutationHookOptions = _objectWithoutPropertiesLoose(_ref, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
var updateQuery = _a.updateQuery,
idField = _a.idField,
operationType = _a.operationType,
mapResultToUpdate = _a.mapResultToUpdate,
mutationHookOptions = __rest(_a, ["updateQuery", "idField", "operationType", "mapResultToUpdate"]);
var _ApolloReactHooks$use = useMutation$1(mutation, mutationHookOptions),
mutationFunction = _ApolloReactHooks$use[0],
mutationResult = _ApolloReactHooks$use[1];
var _b = useMutation$1(mutation, mutationHookOptions),
mutationFunction = _b[0],
mutationResult = _b[1];
var enhancedMutationFunction = function enhancedMutationFunction(mutationFunctionOptions) {
return mutationFunction(getMutationOptions(__assign({
return mutationFunction(getMutationOptions(_extends({
updateQuery: updateQuery,

@@ -290,0 +318,0 @@ idField: idField,

{
"version": "0.1.7",
"version": "0.1.8",
"license": "MIT",

@@ -30,3 +30,3 @@ "name": "apollo-offline-hooks",

"peerDependencies": {
"@apollo/react-hooks": "^3.1.3"
"@apollo/react-hooks": "^3.1.4"
},

@@ -62,22 +62,22 @@ "husky": {

"devDependencies": {
"@apollo/react-common": "^3.1.3",
"@apollo/react-hooks": "^3.1.3",
"@types/jest": "^24.0.25",
"@apollo/react-common": "^3.1.4",
"@apollo/react-hooks": "^3.1.4",
"@types/jest": "^25.2.1",
"apollo-boost": "^0.4.7",
"apollo-cache": "^1.3.4",
"apollo-client": "^2.6.8",
"apollo-link": "^1.2.13",
"apollo-link": "^1.2.14",
"cross-fetch": "^3.0.4",
"graphql": "^14.5.8",
"graphql-tag": "^2.10.1",
"husky": "^4.0.0",
"release-it": "^12.4.3",
"tsdx": "^0.12.1",
"tslib": "^1.10.0",
"typescript": "^3.7.4"
"graphql-tag": "^2.10.3",
"husky": "^4.2.5",
"release-it": "^13.5.2",
"tsdx": "^0.13.1",
"tslib": "^1.11.1",
"typescript": "^3.8.3"
},
"dependencies": {
"apollo-utilities": "^1.3.3",
"immer": "^5.1.0"
"immer": "^6.0.3"
}
}

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

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