1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 | require("isomorphic-unfetch");
|
5 | var _apolloClient;
|
6 | var ssrMode = typeof window === 'undefined';
|
7 | function 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 | }
|
19 | exports.default = initApollo;
|
20 | function 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 |
|
\ | No newline at end of file |