Skip to content

Instantly share code, notes, and snippets.

@ryan-roemer
Created February 22, 2018 17:12
Show Gist options
  • Save ryan-roemer/b59b87feaf12e80677bb508ee54ca039 to your computer and use it in GitHub Desktop.
Save ryan-roemer/b59b87feaf12e80677bb508ee54ca039 to your computer and use it in GitHub Desktop.
urql strict vs. loose mode diff
$ colordiff -Naurw lib-strict lib
diff -Naurw lib-strict/components/client.js lib/components/client.js
--- lib-strict/components/client.js 2018-02-22 09:09:37.000000000 -0800
+++ lib/components/client.js 2018-02-22 09:10:03.000000000 -0800
@@ -11,75 +11,30 @@
var _typenames = require("../modules/typenames");
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
-function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
-
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
-
-function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
-
-function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
+
var UrqlClient =
/*#__PURE__*/
function (_Component) {
- _inherits(UrqlClient, _Component);
+ _inheritsLoose(UrqlClient, _Component);
function UrqlClient() {
- var _ref;
-
var _temp, _this;
- _classCallCheck(this, UrqlClient);
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
- return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_ref = UrqlClient.__proto__ || Object.getPrototypeOf(UrqlClient)).call.apply(_ref, [this].concat(args))), Object.defineProperty(_assertThisInitialized(_this), "state", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: {
+ return (_temp = _this = _Component.call.apply(_Component, [this].concat(args)) || this, _this.state = {
data: null,
error: null,
fetching: false,
loaded: false
- }
- }), Object.defineProperty(_assertThisInitialized(_this), "query", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: null
- }), Object.defineProperty(_assertThisInitialized(_this), "mutations", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: {}
- }), Object.defineProperty(_assertThisInitialized(_this), "typeNames", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: []
- }), Object.defineProperty(_assertThisInitialized(_this), "subscriptionID", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: null
- }), Object.defineProperty(_assertThisInitialized(_this), "invalidate", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function value(queryObject) {
+ }, _this.query = null, _this.mutations = {}, _this.typeNames = [], _this.subscriptionID = null, _this.invalidate = function (queryObject) {
var cache = _this.props.client.cache;
if (queryObject) {
@@ -91,36 +46,16 @@
return cache.invalidate((0, _hash.hashString)(JSON.stringify(q)));
})) : cache.invalidate((0, _hash.hashString)(JSON.stringify(_this.query)));
}
- }
- }), Object.defineProperty(_assertThisInitialized(_this), "invalidateAll", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function value() {
+ }, _this.invalidateAll = function () {
return _this.props.client.cache.invalidateAll();
- }
- }), Object.defineProperty(_assertThisInitialized(_this), "read", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function value(query) {
+ }, _this.read = function (query) {
var formatted = (0, _typenames.formatTypeNames)(query);
var stringified = JSON.stringify(formatted);
var hash = (0, _hash.hashString)(stringified);
return _this.props.client.cache.read(hash);
- }
- }), Object.defineProperty(_assertThisInitialized(_this), "updateCache", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function value(callback) {
+ }, _this.updateCache = function (callback) {
return _this.props.client.cache.update(callback);
- }
- }), Object.defineProperty(_assertThisInitialized(_this), "formatProps", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function value(props) {
+ }, _this.formatProps = function (props) {
// If query exists
if (props.query) {
// Loop through and add typenames
@@ -154,12 +89,7 @@
}
});
}
- }
- }), Object.defineProperty(_assertThisInitialized(_this), "update", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function value(changedTypes, response, refresh) {
+ }, _this.update = function (changedTypes, response, refresh) {
if (refresh === true) {
_this.fetch();
}
@@ -184,25 +114,18 @@
skipCache: true
});
}
- }
- }), Object.defineProperty(_assertThisInitialized(_this), "refreshAllFromCache", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function value() {
+ }, _this.refreshAllFromCache = function () {
return _this.props.client.refreshAllFromCache();
- }
- }), Object.defineProperty(_assertThisInitialized(_this), "fetch", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function value() {
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
+ }, _this.fetch = function (opts, initial) {
+ if (opts === void 0) {
+ opts = {
skipCache: false
};
- var initial = arguments.length > 1 ? arguments[1] : undefined;
+ }
+
var client = _this.props.client;
- var skipCache = opts.skipCache;
+ var _opts = opts,
+ skipCache = _opts.skipCache;
if (_this.props.cache === false) {
skipCache = true;
@@ -248,7 +171,7 @@
return client.executeQuery(query, skipCache).then(function (result) {
if (result.typeNames) {
// Add and dedupe typenames
- _this.typeNames = _toConsumableArray(_this.typeNames).concat(_toConsumableArray(result.typeNames)).filter(function (v, i, a) {
+ _this.typeNames = _this.typeNames.concat(result.typeNames).filter(function (v, i, a) {
return a.indexOf(v) === i;
});
}
@@ -270,12 +193,7 @@
});
});
}
- }
- }), Object.defineProperty(_assertThisInitialized(_this), "mutate", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function value(mutation) {
+ }, _this.mutate = function (mutation) {
var client = _this.props.client; // Set fetching state
_this.setState({
@@ -300,32 +218,28 @@
});
});
});
- }
- }), _temp));
+ }, _temp) || _assertThisInitialized(_this);
}
- _createClass(UrqlClient, [{
- key: "componentDidMount",
+ var _proto = UrqlClient.prototype;
+
// Change subscription ID
- value: function componentDidMount() {
+ _proto.componentDidMount = function componentDidMount() {
this.formatProps(this.props);
- }
- }, {
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(nextProps) {
+ };
+
+ _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (this.props.query !== nextProps.query || this.props.mutation !== nextProps.mutation) {
this.formatProps(nextProps);
}
- }
- }, {
- key: "componentWillUnmount",
- value: function componentWillUnmount() {
+ };
+
+ _proto.componentWillUnmount = function componentWillUnmount() {
// Unsub from change listener
this.props.client.unsubscribe(this.subscriptionID);
- }
- }, {
- key: "render",
- value: function render() {
+ };
+
+ _proto.render = function render() {
var cache = {
invalidate: this.invalidate,
invalidateAll: this.invalidateAll,
@@ -337,19 +251,13 @@
refetch: this.fetch,
refreshAllFromCache: this.refreshAllFromCache
})) : null;
- }
- }]);
+ };
return UrqlClient;
}(_react.Component);
exports.default = UrqlClient;
-Object.defineProperty(UrqlClient, "defaultProps", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: {
+UrqlClient.defaultProps = {
cache: true,
typeInvalidation: true
- }
-});
\ No newline at end of file
+};
\ No newline at end of file
diff -Naurw lib-strict/components/connect-hoc.js lib/components/connect-hoc.js
--- lib-strict/components/connect-hoc.js 2018-02-22 09:09:37.000000000 -0800
+++ lib/components/connect-hoc.js 2018-02-22 09:10:03.000000000 -0800
@@ -13,19 +13,9 @@
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
-
-function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
-
-function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
@@ -34,32 +24,28 @@
return (
/*#__PURE__*/
function (_Component) {
- _inherits(_class, _Component);
+ _inheritsLoose(_class, _Component);
function _class(props) {
var _this;
- _classCallCheck(this, _class);
-
- _this = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this, props));
+ _this = _Component.call(this, props) || this;
_this.renderComponent = _this.renderComponent.bind(_assertThisInitialized(_this));
return _this;
}
- _createClass(_class, [{
- key: "renderComponent",
- value: function renderComponent(data) {
+ var _proto = _class.prototype;
+
+ _proto.renderComponent = function renderComponent(data) {
return _react.default.createElement(Comp, _extends({}, data, this.props));
- }
- }, {
- key: "render",
- value: function render() {
+ };
+
+ _proto.render = function render() {
var connectProps = typeof opts === 'function' ? opts(this.props) : opts;
return _react.default.createElement(_connect.default, _extends({}, connectProps, {
children: this.renderComponent
}));
- }
- }]);
+ };
return _class;
}(_react.Component)
diff -Naurw lib-strict/components/connect.js lib/components/connect.js
--- lib-strict/components/connect.js 2018-02-22 09:09:37.000000000 -0800
+++ lib/components/connect.js 2018-02-22 09:10:03.000000000 -0800
@@ -15,32 +15,20 @@
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
-
-function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
-
-function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Connect =
/*#__PURE__*/
function (_Component) {
- _inherits(Connect, _Component);
+ _inheritsLoose(Connect, _Component);
function Connect() {
- _classCallCheck(this, Connect);
-
- return _possibleConstructorReturn(this, (Connect.__proto__ || Object.getPrototypeOf(Connect)).apply(this, arguments));
+ return _Component.apply(this, arguments) || this;
}
- _createClass(Connect, [{
- key: "render",
- value: function render() {
+ var _proto = Connect.prototype;
+
+ _proto.render = function render() {
var _this = this;
// Use react-create-context to provide context to ClientWrapper
@@ -55,8 +43,7 @@
shouldInvalidate: _this.props.shouldInvalidate
});
});
- }
- }]);
+ };
return Connect;
}(_react.Component);
diff -Naurw lib-strict/components/provider.js lib/components/provider.js
--- lib-strict/components/provider.js 2018-02-22 09:09:38.000000000 -0800
+++ lib/components/provider.js 2018-02-22 09:10:03.000000000 -0800
@@ -11,38 +11,25 @@
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
-
-function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
-
-function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var Provider =
/*#__PURE__*/
function (_Component) {
- _inherits(Provider, _Component);
+ _inheritsLoose(Provider, _Component);
function Provider() {
- _classCallCheck(this, Provider);
-
- return _possibleConstructorReturn(this, (Provider.__proto__ || Object.getPrototypeOf(Provider)).apply(this, arguments));
+ return _Component.apply(this, arguments) || this;
}
- _createClass(Provider, [{
- key: "render",
- value: function render() {
+ var _proto = Provider.prototype;
+
+ _proto.render = function render() {
// Use react-create-context to provide client over context
return _react.default.createElement(_context.Provider, {
value: this.props.client
}, this.props.children);
- }
- }]);
+ };
return Provider;
}(_react.Component);
diff -Naurw lib-strict/modules/client.js lib/modules/client.js
--- lib-strict/modules/client.js 2018-02-22 09:09:38.000000000 -0800
+++ lib/modules/client.js 2018-02-22 09:10:03.000000000 -0800
@@ -15,12 +15,6 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
-
-function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
-
var defaultCache = function defaultCache(store) {
return {
invalidate: function invalidate(hash) {
@@ -71,38 +65,11 @@
// Map of subscribed Connect components
// Cache object
function Client(opts) {
- _classCallCheck(this, Client);
-
- Object.defineProperty(this, "url", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "store", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "fetchOptions", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "subscriptions", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "cache", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: void 0
- });
+ this.url = void 0;
+ this.store = void 0;
+ this.fetchOptions = void 0;
+ this.subscriptions = void 0;
+ this.cache = void 0;
if (!opts) {
throw new Error('Please provide configuration object');
@@ -125,33 +92,30 @@
this.refreshAllFromCache = this.refreshAllFromCache.bind(this);
}
- _createClass(Client, [{
- key: "updateSubscribers",
- value: function updateSubscribers(typenames, changes) {
+ var _proto = Client.prototype;
+
+ _proto.updateSubscribers = function updateSubscribers(typenames, changes) {
// On mutation, call subscribed callbacks with eligible typenames
for (var sub in this.subscriptions) {
if (this.subscriptions.hasOwnProperty(sub)) {
this.subscriptions[sub](typenames, changes);
}
}
- }
- }, {
- key: "subscribe",
- value: function subscribe(callback) {
+ };
+
+ _proto.subscribe = function subscribe(callback) {
// Create an identifier, add callback to subscriptions, return identifier
var id = (0, _v.default)();
this.subscriptions[id] = callback;
return id;
- }
- }, {
- key: "unsubscribe",
- value: function unsubscribe(id) {
+ };
+
+ _proto.unsubscribe = function unsubscribe(id) {
// Delete from subscriptions by identifier
delete this.subscriptions[id];
- }
- }, {
- key: "refreshAllFromCache",
- value: function refreshAllFromCache() {
+ };
+
+ _proto.refreshAllFromCache = function refreshAllFromCache() {
var _this = this;
// On mutation, call subscribed callbacks with eligible typenames
@@ -164,10 +128,9 @@
resolve();
});
- }
- }, {
- key: "executeQuery",
- value: function executeQuery(queryObject, skipCache) {
+ };
+
+ _proto.executeQuery = function executeQuery(queryObject, skipCache) {
var _this2 = this;
return new Promise(function (resolve, reject) {
@@ -223,10 +186,9 @@
}
});
});
- }
- }, {
- key: "executeMutation",
- value: function executeMutation(mutationObject) {
+ };
+
+ _proto.executeMutation = function executeMutation(mutationObject) {
var _this3 = this;
return new Promise(function (resolve, reject) {
@@ -265,8 +227,7 @@
reject(e);
});
});
- }
- }]);
+ };
return Client;
}();
diff -Naurw lib-strict/modules/typenames.js lib/modules/typenames.js
--- lib-strict/modules/typenames.js 2018-02-22 09:09:38.000000000 -0800
+++ lib/modules/typenames.js 2018-02-22 09:10:03.000000000 -0800
@@ -10,8 +10,6 @@
var _printer = require("graphql/language/printer");
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
var TYPENAME_FIELD = {
kind: 'Field',
name: {
@@ -20,8 +18,10 @@
}
};
-function addTypename(selectionSet) {
- var isRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
+function addTypename(selectionSet, isRoot) {
+ if (isRoot === void 0) {
+ isRoot = false;
+ }
if (selectionSet.selections) {
if (!isRoot) {
@@ -74,7 +74,7 @@
function getTypeNameFromField(obj, typenames) {
Object.keys(obj).map(function (item) {
- if (_typeof(obj[item]) === 'object') {
+ if (typeof obj[item] === 'object') {
if (obj[item] && '__typename' in obj[item]) {
typenames.push(obj[item].__typename);
}
diff -Naurw lib-strict/tests/utils/fetch-mock.js lib/tests/utils/fetch-mock.js
--- lib-strict/tests/utils/fetch-mock.js 2018-02-22 09:09:38.000000000 -0800
+++ lib/tests/utils/fetch-mock.js 2018-02-22 09:10:04.000000000 -0800
@@ -5,30 +5,17 @@
});
exports.default = exports.FetchMock = void 0;
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
-
-function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
-
var FetchMock =
/*#__PURE__*/
function () {
function FetchMock() {
- _classCallCheck(this, FetchMock);
-
- Object.defineProperty(this, "fetchCache", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: void 0
- });
+ this.fetchCache = void 0;
this.fetchCache = null;
}
- _createClass(FetchMock, [{
- key: "mockResponse",
- value: function mockResponse(data) {
+ var _proto = FetchMock.prototype;
+
+ _proto.mockResponse = function mockResponse(data) {
// @ts-ignore
this.fetchCache = global.fetch; // @ts-ignore
@@ -43,10 +30,9 @@
});
});
};
- }
- }, {
- key: "mockError",
- value: function mockError(e) {
+ };
+
+ _proto.mockError = function mockError(e) {
// @ts-ignore
this.fetchCache = global.fetch; // @ts-ignore
@@ -55,14 +41,12 @@
throw new Error(e);
});
};
- }
- }, {
- key: "restore",
- value: function restore() {
+ };
+
+ _proto.restore = function restore() {
// @ts-ignore
global.fetch = this.fetchCache;
- }
- }]);
+ };
return FetchMock;
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment