UNPKG

896 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3// Polyfill fetch
4require("isomorphic-unfetch");
5var _apolloClient;
6var ssrMode = typeof window === 'undefined';
7function initApollo(clientFn, options) {
8 if (!clientFn) {
9 throw new Error('[withApollo] the first param is missing and is required to get the ApolloClient');
10 }
11 if (ssrMode) {
12 return getClient(clientFn, options);
13 }
14 if (!_apolloClient) {
15 _apolloClient = getClient(clientFn, options);
16 }
17 return _apolloClient;
18}
19exports.default = initApollo;
20function getClient(clientFn, options) {
21 if (options === void 0) { options = {}; }
22 if (typeof clientFn !== 'function') {
23 throw new Error('[withApollo] requires a function that returns an ApolloClient');
24 }
25 return clientFn(options);
26}
27//# sourceMappingURL=apollo.js.map
\No newline at end of file