-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathindex.js
37 lines (29 loc) · 855 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { createElement } = require('react');
const { fetch } = require('cross-fetch');
let client;
const { ApolloClient, HttpLink, ApolloProvider, InMemoryCache } = (() => {
const { ApolloClient, HttpLink, ApolloProvider } = require('@apollo/client');
const { InMemoryCache } = require('@apollo/client/cache');
return { ApolloClient, HttpLink, ApolloProvider, InMemoryCache };
})();
function createTestClient() {
if (client) {
return client;
}
client = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: 'http://dasistegalhier.com',
fetch,
}),
queryDeduplication: false,
});
return client;
}
function withApolloTestProvider(App) {
return createElement(ApolloProvider, { client: createTestClient() }, App);
}
module.exports = {
createTestClient,
withApolloTestProvider,
};