UNPKG

1.85 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5require('../utilities/globals');
6var context = require('./context');
7var hooks = require('./hooks');
8var parser = require('./parser');
9var tslib = require('tslib');
10var internal = require('./internal');
11
12var wrapperSymbol = Symbol.for("apollo.hook.wrappers");
13function wrapHook(hookName, useHook, clientOrObsQuery) {
14 var queryManager = clientOrObsQuery["queryManager"];
15 var wrappers = queryManager && queryManager[wrapperSymbol];
16 var wrapper = wrappers && wrappers[hookName];
17 return wrapper ? wrapper(useHook) : useHook;
18}
19
20function createQueryPreloader(client) {
21 return wrapHook("createQueryPreloader", _createQueryPreloader, client)(client);
22}
23var _createQueryPreloader = function (client) {
24 return function preloadQuery(query, options) {
25 var _a, _b;
26 if (options === void 0) { options = Object.create(null); }
27 var queryRef = new internal.InternalQueryReference(client.watchQuery(tslib.__assign(tslib.__assign({}, options), { query: query })), {
28 autoDisposeTimeoutMs: (_b = (_a = client.defaultOptions.react) === null || _a === void 0 ? void 0 : _a.suspense) === null || _b === void 0 ? void 0 : _b.autoDisposeTimeoutMs,
29 });
30 return internal.wrapQueryRef(queryRef);
31 };
32};
33
34exports.ApolloConsumer = context.ApolloConsumer;
35exports.ApolloProvider = context.ApolloProvider;
36exports.getApolloContext = context.getApolloContext;
37exports.resetApolloContext = context.resetApolloContext;
38exports.DocumentType = parser.DocumentType;
39exports.operationName = parser.operationName;
40exports.parser = parser.parser;
41exports.createQueryPreloader = createQueryPreloader;
42for (var k in hooks) {
43 if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = hooks[k];
44}
45//# sourceMappingURL=react.cjs.map