1 | import React, { useContext } from 'react';
|
2 | var ApolloContext = React.createContext(null);
|
3 | export function ApolloProvider(_ref) {
|
4 | var client = _ref.client,
|
5 | children = _ref.children;
|
6 | return React.createElement(ApolloContext.Provider, {
|
7 | value: client
|
8 | }, children);
|
9 | }
|
10 | export function useApolloClient(overrideClient) {
|
11 | var client = useContext(ApolloContext);
|
12 |
|
13 |
|
14 |
|
15 | if (overrideClient) {
|
16 | return overrideClient;
|
17 | }
|
18 |
|
19 | if (!client) {
|
20 |
|
21 | throw new Error('Could not find "client" in the context or passed in as a prop. ' + 'Wrap the root component in an <ApolloProvider>, or pass an ' + 'ApolloClient instance in via props.');
|
22 | }
|
23 |
|
24 | return client;
|
25 | } |
\ | No newline at end of file |