@shopify/react-graphql
Advanced tools
Comparing version 6.3.10 to 7.0.0
@@ -1,14 +0,13 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ApolloContext = void 0; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var React = require('react'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var ApolloContext = /*#__PURE__*/_react["default"].createContext(undefined); | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
exports.ApolloContext = ApolloContext; | ||
const ApolloContext = /*#__PURE__*/React__default['default'].createContext(undefined); | ||
exports.ApolloContext = ApolloContext; |
@@ -1,27 +0,27 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ApolloProvider = ApolloProvider; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var React = require('react'); | ||
var reactCommon = require('@apollo/react-common'); | ||
var ApolloContext = require('./ApolloContext.js'); | ||
var _reactCommon = require("@apollo/react-common"); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var _ApolloContext = require("./ApolloContext.js"); | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function ApolloProvider(_ref) { | ||
var client = _ref.client, | ||
children = _ref.children; | ||
return /*#__PURE__*/_react["default"].createElement(_reactCommon.ApolloProvider, { | ||
function ApolloProvider({ | ||
client, | ||
children | ||
}) { | ||
return /*#__PURE__*/React__default['default'].createElement(reactCommon.ApolloProvider, { | ||
client: client | ||
}, /*#__PURE__*/_react["default"].createElement(_ApolloContext.ApolloContext.Provider, { | ||
}, /*#__PURE__*/React__default['default'].createElement(ApolloContext.ApolloContext.Provider, { | ||
value: { | ||
client: client, | ||
client, | ||
operations: client.__operations_cache__ | ||
} | ||
}, children)); | ||
} | ||
} | ||
exports.ApolloProvider = ApolloProvider; |
@@ -1,23 +0,20 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createAsyncQueryComponent = createAsyncQueryComponent; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _reactIdle = require("@shopify/react-idle"); | ||
var reactIdle = require('@shopify/react-idle'); | ||
var query = require('./query.js'); | ||
var query$1 = require('../hooks/query.js'); | ||
var _index = require("../hooks/index.js"); | ||
var _query = require("./query.js"); | ||
function createAsyncQueryComponent(options) { | ||
var asyncQuery = (0, _query.createAsyncQuery)(options); | ||
var resolver = asyncQuery.resolver, | ||
usePreload = asyncQuery.usePreload, | ||
usePrefetch = asyncQuery.usePrefetch, | ||
useKeepFresh = asyncQuery.useKeepFresh; | ||
const asyncQuery = query.createAsyncQuery(options); | ||
const { | ||
resolver, | ||
usePreload, | ||
usePrefetch, | ||
useKeepFresh | ||
} = asyncQuery; | ||
function AsyncQuery(options) { | ||
var result = (0, _index.useQuery)(asyncQuery, options); | ||
const result = query$1['default'](asyncQuery, options); | ||
return options.children(result); | ||
@@ -27,3 +24,3 @@ } | ||
function Preload() { | ||
(0, _reactIdle.useIdleCallback)(usePreload()); | ||
reactIdle.useIdleCallback(usePreload()); | ||
return null; | ||
@@ -33,3 +30,3 @@ } | ||
function Prefetch(options) { | ||
(0, _reactIdle.useIdleCallback)(usePrefetch(options)); | ||
reactIdle.useIdleCallback(usePrefetch(options)); | ||
return null; | ||
@@ -39,3 +36,3 @@ } | ||
function KeepFresh(options) { | ||
(0, _reactIdle.useIdleCallback)(useKeepFresh(options)); | ||
reactIdle.useIdleCallback(useKeepFresh(options)); | ||
return null; | ||
@@ -47,3 +44,3 @@ } // Once we upgrade past TS 3.1, this will no longer be necessary, | ||
var FinalComponent = AsyncQuery; | ||
const FinalComponent = AsyncQuery; | ||
Reflect.defineProperty(FinalComponent, 'resolver', { | ||
@@ -78,2 +75,4 @@ value: resolver, | ||
return FinalComponent; | ||
} | ||
} | ||
exports.createAsyncQueryComponent = createAsyncQueryComponent; |
@@ -1,31 +0,22 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createAsyncQuery = createAsyncQuery; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _async = require("@shopify/async"); | ||
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js'); | ||
var async = require('@shopify/async'); | ||
var reactAsync = require('@shopify/react-async'); | ||
var backgroundQuery = require('../hooks/background-query.js'); | ||
var _reactAsync = require("@shopify/react-async"); | ||
var _index = require("../hooks/index.js"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function createAsyncQuery(_ref) { | ||
var id = _ref.id, | ||
load = _ref.load; | ||
var resolver = (0, _async.createResolver)({ | ||
id: id, | ||
load: load | ||
function createAsyncQuery({ | ||
id, | ||
load | ||
}) { | ||
const resolver = async.createResolver({ | ||
id, | ||
load | ||
}); | ||
function usePreload() { | ||
return (0, _reactAsync.useAsync)(resolver, { | ||
assets: _reactAsync.AssetTiming.NextPage | ||
return reactAsync.useAsync(resolver, { | ||
assets: reactAsync.AssetTiming.NextPage | ||
}).load; | ||
@@ -35,9 +26,9 @@ } | ||
function usePrefetch(options) { | ||
var load = usePreload(); | ||
return (0, _index.useBackgroundQuery)(load, options); | ||
const load = usePreload(); | ||
return backgroundQuery.useBackgroundQuery(load, options); | ||
} | ||
function useKeepFresh(options) { | ||
var load = usePreload(); | ||
return (0, _index.useBackgroundQuery)(load, _objectSpread({ | ||
const load = usePreload(); | ||
return backgroundQuery.useBackgroundQuery(load, _rollupPluginBabelHelpers.objectSpread2({ | ||
pollInterval: 10000 | ||
@@ -48,7 +39,9 @@ }, options)); | ||
return { | ||
resolver: resolver, | ||
usePreload: usePreload, | ||
usePrefetch: usePrefetch, | ||
useKeepFresh: useKeepFresh | ||
resolver, | ||
usePreload, | ||
usePrefetch, | ||
useKeepFresh | ||
}; | ||
} | ||
} | ||
exports.createAsyncQuery = createAsyncQuery; |
@@ -1,20 +0,17 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = useApolloClient; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var React = require('react'); | ||
var ApolloContext = require('../ApolloContext.js'); | ||
var _ApolloContext = require("../ApolloContext.js"); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
function useApolloClient(overrideClient) { | ||
var context = _react["default"].useContext(_ApolloContext.ApolloContext); // Ensures that the number of hooks called from one render to another remains | ||
const context = React__default['default'].useContext(ApolloContext.ApolloContext); // Ensures that the number of hooks called from one render to another remains | ||
// constant, despite the Apollo client read from context being swapped for | ||
// one passed directly as prop. | ||
if (overrideClient) { | ||
@@ -30,2 +27,4 @@ return overrideClient; | ||
return context.client; | ||
} | ||
} | ||
exports.default = useApolloClient; |
@@ -1,34 +0,17 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.useBackgroundQuery = useBackgroundQuery; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js'); | ||
var React = require('react'); | ||
var apolloClient = require('./apollo-client.js'); | ||
var _react = require("react"); | ||
var _apolloClient = _interopRequireDefault(require("./apollo-client.js")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
function useBackgroundQuery(load, options) { | ||
var client = (0, _apolloClient["default"])(); | ||
var lastClient = (0, _react.useRef)(client); | ||
var lastOptions = (0, _react.useRef)(options); | ||
var serializedOptions = JSON.stringify(options); | ||
var lastSerializedOptions = (0, _react.useRef)(serializedOptions); | ||
var subscription = (0, _react.useRef)(null); | ||
var polling = (0, _react.useRef)(Boolean(options && options.pollInterval)); | ||
const client = apolloClient['default'](); | ||
const lastClient = React.useRef(client); | ||
const lastOptions = React.useRef(options); | ||
const serializedOptions = JSON.stringify(options); | ||
const lastSerializedOptions = React.useRef(serializedOptions); | ||
const subscription = React.useRef(null); | ||
const polling = React.useRef(Boolean(options && options.pollInterval)); | ||
@@ -43,61 +26,37 @@ if (subscription.current != null && (lastClient.current !== client || lastSerializedOptions.current !== serializedOptions)) { | ||
lastSerializedOptions.current = serializedOptions; | ||
(0, _react.useEffect)(function () { | ||
return function () { | ||
if (subscription.current) { | ||
subscription.current.unsubscribe(); | ||
subscription.current = null; | ||
} | ||
}; | ||
React.useEffect(() => () => { | ||
if (subscription.current) { | ||
subscription.current.unsubscribe(); | ||
subscription.current = null; | ||
} | ||
}, []); | ||
return (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() { | ||
var query, observableQuery, unsubscribe; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!subscription.current) { | ||
_context.next = 2; | ||
break; | ||
} | ||
return React.useCallback( /*#__PURE__*/_rollupPluginBabelHelpers.asyncToGenerator(function* () { | ||
if (subscription.current) { | ||
return; | ||
} | ||
return _context.abrupt("return"); | ||
const query = yield load(); | ||
case 2: | ||
_context.next = 4; | ||
return load(); | ||
if (query == null || query instanceof Error) { | ||
return; | ||
} | ||
case 4: | ||
query = _context.sent; | ||
const observableQuery = lastClient.current.watchQuery(_rollupPluginBabelHelpers.objectSpread2({ | ||
query, | ||
fetchPolicy: 'network-only' | ||
}, lastOptions.current)); | ||
if (!(query == null || query instanceof Error)) { | ||
_context.next = 7; | ||
break; | ||
} | ||
const unsubscribe = () => { | ||
if (polling.current || subscription.current == null) { | ||
return; | ||
} | ||
return _context.abrupt("return"); | ||
subscription.current.unsubscribe(); | ||
subscription.current = null; | ||
}; | ||
case 7: | ||
observableQuery = lastClient.current.watchQuery(_objectSpread({ | ||
query: query, | ||
fetchPolicy: 'network-only' | ||
}, lastOptions.current)); | ||
subscription.current = observableQuery.subscribe(unsubscribe, unsubscribe); | ||
}), [load]); | ||
} | ||
unsubscribe = function unsubscribe() { | ||
if (polling.current || subscription.current == null) { | ||
return; | ||
} | ||
subscription.current.unsubscribe(); | ||
subscription.current = null; | ||
}; | ||
subscription.current = observableQuery.subscribe(unsubscribe, unsubscribe); | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
})), [load]); | ||
} | ||
exports.useBackgroundQuery = useBackgroundQuery; |
@@ -1,36 +0,12 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = useGraphQLDocument; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js'); | ||
var React = require('react'); | ||
var reactHooks = require('@shopify/react-hooks'); | ||
var reactAsync = require('@shopify/react-async'); | ||
var _react = require("react"); | ||
var _reactHooks = require("@shopify/react-hooks"); | ||
var _reactAsync = require("@shopify/react-async"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function useGraphQLDocument(documentOrAsyncDocument) { | ||
var _useState = (0, _react.useState)(function () { | ||
const [document, setDocument] = React.useState(() => { | ||
if (isDocumentNode(documentOrAsyncDocument)) { | ||
@@ -41,46 +17,18 @@ return documentOrAsyncDocument; | ||
} | ||
}), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
document = _useState2[0], | ||
setDocument = _useState2[1]; | ||
}); | ||
const mounted = reactHooks.useMountedRef(); | ||
const loadDocument = React.useCallback( /*#__PURE__*/_rollupPluginBabelHelpers.asyncToGenerator(function* () { | ||
if (!isDocumentNode(documentOrAsyncDocument)) { | ||
try { | ||
const resolved = yield documentOrAsyncDocument.resolver.resolve(); | ||
var mounted = (0, _reactHooks.useMountedRef)(); | ||
var loadDocument = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() { | ||
var resolved; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (isDocumentNode(documentOrAsyncDocument)) { | ||
_context.next = 11; | ||
break; | ||
} | ||
_context.prev = 1; | ||
_context.next = 4; | ||
return documentOrAsyncDocument.resolver.resolve(); | ||
case 4: | ||
resolved = _context.sent; | ||
if (mounted.current) { | ||
setDocument(resolved); | ||
} | ||
_context.next = 11; | ||
break; | ||
case 8: | ||
_context.prev = 8; | ||
_context.t0 = _context["catch"](1); | ||
throw Error('error loading GraphQL document'); | ||
case 11: | ||
case "end": | ||
return _context.stop(); | ||
if (mounted.current) { | ||
setDocument(resolved); | ||
} | ||
} catch (error) { | ||
throw Error('error loading GraphQL document'); | ||
} | ||
}, _callee, null, [[1, 8]]); | ||
})), [documentOrAsyncDocument, mounted]); | ||
(0, _react.useEffect)(function () { | ||
} | ||
}), [documentOrAsyncDocument, mounted]); | ||
React.useEffect(() => { | ||
if (!document) { | ||
@@ -90,3 +38,3 @@ loadDocument(); | ||
}, [document, loadDocument]); | ||
(0, _reactAsync.useAsyncAsset)(isDocumentNode(documentOrAsyncDocument) ? undefined : documentOrAsyncDocument.resolver.id); | ||
reactAsync.useAsyncAsset(isDocumentNode(documentOrAsyncDocument) ? undefined : documentOrAsyncDocument.resolver.id); | ||
return document; | ||
@@ -97,2 +45,4 @@ } | ||
return Boolean(arg && arg.kind && arg.kind === 'Document'); | ||
} | ||
} | ||
exports.default = useGraphQLDocument; |
@@ -1,46 +0,34 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = useMutation; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _react = require("react"); | ||
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js'); | ||
var React = require('react'); | ||
var apolloClient = require('./apollo-client.js'); | ||
var _apolloClient = _interopRequireDefault(require("./apollo-client.js")); | ||
function useMutation(mutation, options = {}) { | ||
const { | ||
client: overrideClient, | ||
variables, | ||
optimisticResponse, | ||
refetchQueries, | ||
awaitRefetchQueries, | ||
update, | ||
context, | ||
fetchPolicy | ||
} = options; | ||
const client = apolloClient['default'](overrideClient); | ||
const runMutation = React.useCallback((perMutationOptions = {}) => { | ||
const mutateVariables = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, variables || {}), perMutationOptions.variables || {}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function useMutation(mutation) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var overrideClient = options.client, | ||
variables = options.variables, | ||
optimisticResponse = options.optimisticResponse, | ||
refetchQueries = options.refetchQueries, | ||
awaitRefetchQueries = options.awaitRefetchQueries, | ||
update = options.update, | ||
context = options.context, | ||
fetchPolicy = options.fetchPolicy; | ||
var client = (0, _apolloClient["default"])(overrideClient); | ||
var runMutation = (0, _react.useCallback)(function () { | ||
var perMutationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var mutateVariables = _objectSpread(_objectSpread({}, variables || {}), perMutationOptions.variables || {}); | ||
delete perMutationOptions.variables; | ||
return client.mutate(_objectSpread({ | ||
mutation: mutation, | ||
return client.mutate(_rollupPluginBabelHelpers.objectSpread2({ | ||
mutation, | ||
variables: mutateVariables, | ||
optimisticResponse: optimisticResponse, | ||
refetchQueries: refetchQueries, | ||
awaitRefetchQueries: awaitRefetchQueries, | ||
update: update, | ||
context: context, | ||
fetchPolicy: fetchPolicy | ||
optimisticResponse, | ||
refetchQueries, | ||
awaitRefetchQueries, | ||
update, | ||
context, | ||
fetchPolicy | ||
}, perMutationOptions)); | ||
@@ -52,2 +40,4 @@ }, // eslint-disable-next-line react-hooks/exhaustive-deps | ||
return runMutation; | ||
} | ||
} | ||
exports.default = useMutation; |
@@ -1,58 +0,27 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = useQuery; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _react = require("react"); | ||
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js'); | ||
var React = require('react'); | ||
var apolloClient$1 = require('apollo-client'); | ||
var reactEffect = require('@shopify/react-effect'); | ||
var apolloClient = require('./apollo-client.js'); | ||
var graphqlDocument = require('./graphql-document.js'); | ||
var _apolloClient = require("apollo-client"); | ||
function useQuery(queryOrAsyncQuery, ...optionsPart) { | ||
const [options = {}] = optionsPart; | ||
const { | ||
skip = false, | ||
fetchPolicy, | ||
errorPolicy, | ||
pollInterval, | ||
client: overrideClient, | ||
notifyOnNetworkStatusChange, | ||
context, | ||
ssr = true | ||
} = options; | ||
const variables = options.variables || {}; | ||
const client = apolloClient['default'](overrideClient); | ||
var _reactEffect = require("@shopify/react-effect"); | ||
var _apolloClient2 = _interopRequireDefault(require("./apollo-client.js")); | ||
var _graphqlDocument = _interopRequireDefault(require("./graphql-document.js")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function useQuery(queryOrAsyncQuery) { | ||
for (var _len = arguments.length, optionsPart = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
optionsPart[_key - 1] = arguments[_key]; | ||
} | ||
var _optionsPart$ = optionsPart[0], | ||
options = _optionsPart$ === void 0 ? {} : _optionsPart$; | ||
var _options$skip = options.skip, | ||
skip = _options$skip === void 0 ? false : _options$skip, | ||
fetchPolicy = options.fetchPolicy, | ||
errorPolicy = options.errorPolicy, | ||
pollInterval = options.pollInterval, | ||
overrideClient = options.client, | ||
notifyOnNetworkStatusChange = options.notifyOnNetworkStatusChange, | ||
context = options.context, | ||
_options$ssr = options.ssr, | ||
ssr = _options$ssr === void 0 ? true : _options$ssr; | ||
var variables = options.variables || {}; | ||
var client = (0, _apolloClient2["default"])(overrideClient); | ||
if (typeof window === 'undefined' && (skip || fetchPolicy === 'no-cache' || !ssr)) { | ||
@@ -62,6 +31,6 @@ return createDefaultResult(client, variables); | ||
var query = (0, _graphqlDocument["default"])(queryOrAsyncQuery); | ||
var normalizedFetchPolicy = typeof window === 'undefined' && (fetchPolicy === 'network-only' || fetchPolicy === 'cache-and-network') ? 'cache-first' : fetchPolicy; | ||
var serializedVariables = variables && JSON.stringify(variables); | ||
var watchQueryOptions = (0, _react.useMemo)(function () { | ||
const query = graphqlDocument['default'](queryOrAsyncQuery); | ||
const normalizedFetchPolicy = typeof window === 'undefined' && (fetchPolicy === 'network-only' || fetchPolicy === 'cache-and-network') ? 'cache-first' : fetchPolicy; | ||
const serializedVariables = variables && JSON.stringify(variables); | ||
const watchQueryOptions = React.useMemo(() => { | ||
if (!query) { | ||
@@ -72,13 +41,13 @@ return null; | ||
return { | ||
query: query, | ||
context: context, | ||
variables: variables, | ||
query, | ||
context, | ||
variables, | ||
fetchPolicy: normalizedFetchPolicy, | ||
errorPolicy: errorPolicy, | ||
pollInterval: pollInterval, | ||
notifyOnNetworkStatusChange: notifyOnNetworkStatusChange | ||
errorPolicy, | ||
pollInterval, | ||
notifyOnNetworkStatusChange | ||
}; // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [query, // eslint-disable-next-line react-hooks/exhaustive-deps | ||
context && JSON.stringify(context), serializedVariables, normalizedFetchPolicy, errorPolicy, pollInterval, notifyOnNetworkStatusChange]); | ||
var queryObservable = (0, _react.useMemo)(function () { | ||
const queryObservable = React.useMemo(() => { | ||
if (skip || !watchQueryOptions) { | ||
@@ -90,3 +59,3 @@ return; | ||
}, [client, skip, watchQueryOptions]); | ||
(0, _reactEffect.useServerEffect)(function () { | ||
reactEffect.useServerEffect(() => { | ||
if (queryObservable == null) { | ||
@@ -96,16 +65,9 @@ return; | ||
var result = queryObservable.getCurrentResult(); | ||
const result = queryObservable.getCurrentResult(); | ||
return result.loading ? queryObservable.result() : undefined; | ||
}); | ||
var defaultResult = (0, _react.useMemo)(function () { | ||
return createDefaultResult(client, variables, queryObservable); | ||
}, // eslint-disable-next-line react-hooks/exhaustive-deps | ||
const defaultResult = React.useMemo(() => createDefaultResult(client, variables, queryObservable), // eslint-disable-next-line react-hooks/exhaustive-deps | ||
[queryObservable, client, serializedVariables]); | ||
var _useState = (0, _react.useState)(0), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
responseId = _useState2[0], | ||
setResponseId = _useState2[1]; | ||
(0, _react.useEffect)(function () { | ||
const [responseId, setResponseId] = React.useState(0); | ||
React.useEffect(() => { | ||
if (skip || !queryObservable) { | ||
@@ -115,15 +77,13 @@ return; | ||
var invalidateCurrentResult = function invalidateCurrentResult() { | ||
setResponseId(function (x) { | ||
return x + 1; | ||
}); | ||
const invalidateCurrentResult = () => { | ||
setResponseId(x => x + 1); | ||
}; | ||
var subscription = queryObservable.subscribe(invalidateCurrentResult, invalidateCurrentResult); | ||
return function () { | ||
const subscription = queryObservable.subscribe(invalidateCurrentResult, invalidateCurrentResult); | ||
return () => { | ||
subscription.unsubscribe(); | ||
}; | ||
}, [skip, queryObservable]); | ||
var previousData = (0, _react.useRef)(undefined); | ||
var currentResult = (0, _react.useMemo)(function () { | ||
const previousData = React.useRef(undefined); | ||
const currentResult = React.useMemo(() => { | ||
// must of the logic below are lifted from | ||
@@ -136,3 +96,3 @@ // https://github.com/apollographql/react-apollo/blob/22f8ebf52b26b348d6be905d5b7fbbfea51c1541/src/Query.tsx#L410-L477 | ||
if (!queryObservable) { | ||
return _objectSpread(_objectSpread({}, defaultResult), {}, { | ||
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, defaultResult), {}, { | ||
// while documentNode is loading | ||
@@ -143,9 +103,11 @@ loading: true | ||
var result = queryObservable.getCurrentResult(); | ||
var fetchPolicy = queryObservable.options.fetchPolicy; | ||
var hasError = result.errors && result.errors.length > 0; | ||
var data = result.data; | ||
const result = queryObservable.getCurrentResult(); | ||
const { | ||
fetchPolicy | ||
} = queryObservable.options; | ||
const hasError = result.errors && result.errors.length > 0; | ||
let data = result.data; | ||
if (result.loading) { | ||
data = previousData.current || result && result.data ? _objectSpread(_objectSpread({}, previousData.current || {}), result && result.data || {}) : undefined; | ||
data = previousData.current || result && result.data ? _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, previousData.current || {}), result && result.data || {}) : undefined; | ||
} else if (hasError) { | ||
@@ -159,5 +121,5 @@ data = (queryObservable.getLastResult() || {}).data; | ||
return _objectSpread(_objectSpread({}, defaultResult), {}, { | ||
data: data, | ||
error: hasError ? new _apolloClient.ApolloError({ | ||
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, defaultResult), {}, { | ||
data, | ||
error: hasError ? new apolloClient$1.ApolloError({ | ||
graphQLErrors: result.errors | ||
@@ -186,6 +148,8 @@ }) : result.error, | ||
subscribeToMore: queryObservable ? queryObservable.subscribeToMore.bind(queryObservable) : noop, | ||
client: client | ||
client | ||
}; | ||
} | ||
function noop() {} | ||
function noop() {} | ||
exports.default = useQuery; |
@@ -1,89 +0,35 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _exportNames = { | ||
DeferTiming: true, | ||
Query: true, | ||
Prefetch: true, | ||
createAsyncQueryComponent: true, | ||
createAsyncQuery: true, | ||
ApolloProvider: true, | ||
createSsrExtractableLink: true, | ||
SsrExtractableLink: true | ||
}; | ||
Object.defineProperty(exports, "DeferTiming", { | ||
enumerable: true, | ||
get: function get() { | ||
return _async.DeferTiming; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Query", { | ||
enumerable: true, | ||
get: function get() { | ||
return _Query.Query; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Prefetch", { | ||
enumerable: true, | ||
get: function get() { | ||
return _Prefetch.Prefetch; | ||
} | ||
}); | ||
Object.defineProperty(exports, "createAsyncQueryComponent", { | ||
enumerable: true, | ||
get: function get() { | ||
return _index.createAsyncQueryComponent; | ||
} | ||
}); | ||
Object.defineProperty(exports, "createAsyncQuery", { | ||
enumerable: true, | ||
get: function get() { | ||
return _index.createAsyncQuery; | ||
} | ||
}); | ||
Object.defineProperty(exports, "ApolloProvider", { | ||
enumerable: true, | ||
get: function get() { | ||
return _ApolloProvider.ApolloProvider; | ||
} | ||
}); | ||
Object.defineProperty(exports, "createSsrExtractableLink", { | ||
enumerable: true, | ||
get: function get() { | ||
return _links.createSsrExtractableLink; | ||
} | ||
}); | ||
Object.defineProperty(exports, "SsrExtractableLink", { | ||
enumerable: true, | ||
get: function get() { | ||
return _links.SsrExtractableLink; | ||
} | ||
}); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _async = require("@shopify/async"); | ||
var async = require('@shopify/async'); | ||
var Query = require('./Query.js'); | ||
var Prefetch = require('./Prefetch.js'); | ||
var ApolloProvider = require('./ApolloProvider.js'); | ||
var links = require('./links.js'); | ||
var apolloClient = require('./hooks/apollo-client.js'); | ||
var query$1 = require('./hooks/query.js'); | ||
var mutation = require('./hooks/mutation.js'); | ||
var component = require('./async/component.js'); | ||
var query = require('./async/query.js'); | ||
var backgroundQuery = require('./hooks/background-query.js'); | ||
var _Query = require("./Query.js"); | ||
var _Prefetch = require("./Prefetch.js"); | ||
var _index = require("./async/index.js"); | ||
var _ApolloProvider = require("./ApolloProvider.js"); | ||
var _links = require("./links.js"); | ||
var _index2 = require("./hooks/index.js"); | ||
Object.keys(_index2).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _index2[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _index2[key]; | ||
} | ||
}); | ||
}); | ||
Object.defineProperty(exports, 'DeferTiming', { | ||
enumerable: true, | ||
get: function () { | ||
return async.DeferTiming; | ||
} | ||
}); | ||
exports.Query = Query.Query; | ||
exports.Prefetch = Prefetch.Prefetch; | ||
exports.ApolloProvider = ApolloProvider.ApolloProvider; | ||
exports.SsrExtractableLink = links.SsrExtractableLink; | ||
exports.createSsrExtractableLink = links.createSsrExtractableLink; | ||
exports.useApolloClient = apolloClient['default']; | ||
exports.useQuery = query$1['default']; | ||
exports.useMutation = mutation['default']; | ||
exports.createAsyncQueryComponent = component.createAsyncQueryComponent; | ||
exports.createAsyncQuery = query.createAsyncQuery; | ||
exports.useBackgroundQuery = backgroundQuery.useBackgroundQuery; |
@@ -1,111 +0,53 @@ | ||
"use strict"; | ||
'use strict'; | ||
function _typeof(obj) { "@babel/helpers - typeof"; 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); } | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createSsrExtractableLink = createSsrExtractableLink; | ||
exports.SsrExtractableLink = void 0; | ||
var apolloLink = require('apollo-link'); | ||
var _apolloLink = require("apollo-link"); | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
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 _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, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function createSsrExtractableLink() { | ||
return new SsrExtractableLink(); | ||
} | ||
class SsrExtractableLink extends apolloLink.ApolloLink { | ||
constructor(...args) { | ||
super(...args); | ||
this.operations = new Set(); | ||
} | ||
var SsrExtractableLink = /*#__PURE__*/function (_ApolloLink) { | ||
_inherits(SsrExtractableLink, _ApolloLink); | ||
var _super = _createSuper(SsrExtractableLink); | ||
function SsrExtractableLink() { | ||
var _this; | ||
_classCallCheck(this, SsrExtractableLink); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
resolveAll(then) { | ||
if (this.operations.size > 0) { | ||
return Promise.all([...this.operations]).then(then); | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this.operations = new Set(); | ||
return _this; | ||
return then(); | ||
} | ||
_createClass(SsrExtractableLink, [{ | ||
key: "resolveAll", | ||
value: function resolveAll(then) { | ||
if (this.operations.size > 0) { | ||
return Promise.all(_toConsumableArray(this.operations)).then(then); | ||
} | ||
return then(); | ||
request(operation, nextLink) { | ||
if (nextLink == null) { | ||
throw new Error('SsrExtractableLink must not be the last link in the chain.'); | ||
} | ||
}, { | ||
key: "request", | ||
value: function request(operation, nextLink) { | ||
var _this2 = this; | ||
if (nextLink == null) { | ||
throw new Error('SsrExtractableLink must not be the last link in the chain.'); | ||
} | ||
let operationDone; | ||
const promise = new Promise(resolve => { | ||
operationDone = () => { | ||
this.operations.delete(promise); | ||
resolve(); | ||
}; | ||
}); | ||
this.operations.add(promise); | ||
return new apolloLink.Observable(observer => { | ||
return nextLink(operation).subscribe({ | ||
complete() { | ||
observer.complete(); | ||
operationDone(); | ||
}, | ||
var operationDone; | ||
var promise = new Promise(function (resolve) { | ||
operationDone = function operationDone() { | ||
_this2.operations["delete"](promise); | ||
resolve(); | ||
}; | ||
next: observer.next.bind(observer), | ||
error: observer.next.bind(observer) | ||
}); | ||
this.operations.add(promise); | ||
return new _apolloLink.Observable(function (observer) { | ||
return nextLink(operation).subscribe({ | ||
complete: function complete() { | ||
observer.complete(); | ||
operationDone(); | ||
}, | ||
next: observer.next.bind(observer), | ||
error: observer.next.bind(observer) | ||
}); | ||
}); | ||
} | ||
}]); | ||
}); | ||
} | ||
return SsrExtractableLink; | ||
}(_apolloLink.ApolloLink); | ||
} | ||
exports.SsrExtractableLink = SsrExtractableLink; | ||
exports.SsrExtractableLink = SsrExtractableLink; | ||
exports.createSsrExtractableLink = createSsrExtractableLink; |
@@ -1,28 +0,25 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Prefetch = Prefetch; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js'); | ||
var React = require('react'); | ||
var Query = require('./Query.js'); | ||
var _Query = require("./Query.js"); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
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 Prefetch(_ref) { | ||
var ignoreCache = _ref.ignoreCache, | ||
props = _objectWithoutProperties(_ref, ["ignoreCache"]); | ||
let { | ||
ignoreCache | ||
} = _ref, | ||
props = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, ["ignoreCache"]); | ||
var fetchPolicy = ignoreCache ? 'network-only' : undefined; | ||
return /*#__PURE__*/_react["default"].createElement(_Query.Query, Object.assign({}, props, { | ||
const fetchPolicy = ignoreCache ? 'network-only' : undefined; | ||
return /*#__PURE__*/React__default['default'].createElement(Query.Query, Object.assign({}, props, { | ||
fetchPolicy: fetchPolicy | ||
}), function () { | ||
return null; | ||
}); | ||
} | ||
}), () => null); | ||
} | ||
exports.Prefetch = Prefetch; |
@@ -1,24 +0,20 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Query = Query; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _index = require("./hooks/index.js"); | ||
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js'); | ||
var query = require('./hooks/query.js'); | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
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 Query(_ref) { | ||
var children = _ref.children, | ||
query = _ref.query, | ||
options = _objectWithoutProperties(_ref, ["children", "query"]); | ||
let { | ||
children, | ||
query: query$1 | ||
} = _ref, | ||
options = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, ["children", "query"]); | ||
var opts = [options]; | ||
const opts = [options]; | ||
const result = query['default'](query$1, ...opts); | ||
return children(result); | ||
} | ||
var result = _index.useQuery.apply(void 0, [query].concat(opts)); | ||
return children(result); | ||
} | ||
exports.Query = Query; |
@@ -10,2 +10,8 @@ # Changelog | ||
## 7.0.0 - 2021-05-21 | ||
### Breaking Change | ||
- Update minimum supported node version to 12.14.0. Add engines field to help enforce usage of this version. [#1906](https://github.com/Shopify/quilt/pull/1906) | ||
## 6.3.6 - 2021-04-13 | ||
@@ -12,0 +18,0 @@ |
{ | ||
"name": "@shopify/react-graphql", | ||
"version": "6.3.10", | ||
"version": "7.0.0", | ||
"license": "MIT", | ||
@@ -23,18 +23,21 @@ "description": "Tools for creating type-safe and asynchronous GraphQL components for React", | ||
"homepage": "https://github.com/Shopify/quilt/blob/main/packages/react-graphql/README.md", | ||
"engines": { | ||
"node": ">=12.14.0" | ||
}, | ||
"dependencies": { | ||
"@apollo/react-common": ">=3.0.0 <4.0.0", | ||
"@apollo/react-hooks": ">=3.0.0 <4.0.0", | ||
"@shopify/async": "^2.2.6", | ||
"@shopify/react-async": "^3.2.8", | ||
"@shopify/react-effect": "^3.3.6", | ||
"@shopify/react-hooks": "^1.13.1", | ||
"@shopify/react-idle": "^1.1.7", | ||
"@shopify/useful-types": "^2.4.2", | ||
"@shopify/async": "^3.0.0", | ||
"@shopify/react-async": "^4.0.0", | ||
"@shopify/react-effect": "^4.0.0", | ||
"@shopify/react-hooks": "^2.0.0", | ||
"@shopify/react-idle": "^2.0.0", | ||
"@shopify/useful-types": "^3.0.0", | ||
"apollo-cache-inmemory": ">=1.0.0 <2.0.0", | ||
"apollo-client": ">=2.0.0 <3.0.0", | ||
"apollo-link": ">=1.0.0 <2.0.0", | ||
"graphql-typed": "^0.7.2" | ||
"graphql-typed": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@shopify/react-testing": "^2.3.5" | ||
"@shopify/react-testing": "^3.0.0" | ||
}, | ||
@@ -62,3 +65,3 @@ "files": [ | ||
}, | ||
"gitHead": "b5c7181efee8d207f741b548524e334d8d9d842f" | ||
"gitHead": "40de4af181104f298cbab42d2d3d68e228a9a31a" | ||
} |
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
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
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
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
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
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116285
100
1749
+ Added@shopify/async@3.1.5(transitive)
+ Added@shopify/react-async@4.1.24(transitive)
+ Added@shopify/react-effect@4.1.12(transitive)
+ Added@shopify/react-hooks@2.1.19(transitive)
+ Added@shopify/react-hydrate@2.1.21(transitive)
+ Added@shopify/react-idle@2.1.14(transitive)
+ Added@shopify/react-intersection-observer@3.1.11(transitive)
+ Added@shopify/useful-types@3.1.04.0.3(transitive)
+ Addedgraphql-typed@1.1.5(transitive)
- Removed@shopify/async@2.2.6(transitive)
- Removed@shopify/react-async@3.2.8(transitive)
- Removed@shopify/react-effect@3.3.6(transitive)
- Removed@shopify/react-hooks@1.13.1(transitive)
- Removed@shopify/react-hydrate@1.2.7(transitive)
- Removed@shopify/react-idle@1.1.7(transitive)
- Removed@shopify/react-intersection-observer@2.1.4(transitive)
- Removed@shopify/useful-types@2.4.2(transitive)
- Removedgraphql-typed@0.7.2(transitive)
Updated@shopify/async@^3.0.0
Updated@shopify/react-async@^4.0.0
Updated@shopify/react-effect@^4.0.0
Updated@shopify/react-hooks@^2.0.0
Updated@shopify/react-idle@^2.0.0
Updated@shopify/useful-types@^3.0.0
Updatedgraphql-typed@^1.0.0