-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathApp.js
39 lines (33 loc) · 745 Bytes
/
App.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
38
39
import React from 'react';
import md5 from 'blueimp-md5';
import {
ApolloClient,
ApolloProvider,
InMemoryCache,
HttpLink,
} from '@apollo/client';
import { XhrAndFetch } from './XhrAndFetch';
import { GraphQL } from './GraphQL';
const customFetch = (uri, options) => {
const bodyHash = md5(options.body);
return fetch(`${uri}?_md5=${bodyHash}`, options);
};
const httpLink = new HttpLink({
uri: 'https://api.spacex.land/graphql',
fetch: customFetch,
});
const client = new ApolloClient({
cache: new InMemoryCache(),
link: httpLink,
});
function App() {
return (
<ApolloProvider client={client}>
<div>
<XhrAndFetch />
<GraphQL />
</div>
</ApolloProvider>
);
}
export default App;