-
-
Notifications
You must be signed in to change notification settings - Fork 445
/
index.tsx
43 lines (38 loc) · 919 Bytes
/
index.tsx
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
40
41
42
43
import React, { FC } from 'react';
import * as ReactDOM from 'react-dom';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import {
cacheExchange,
createClient,
debugExchange,
fetchExchange,
Provider,
subscriptionExchange,
} from 'urql';
import './index.css';
import { Messages } from './Messages';
const subscriptionClient = new SubscriptionClient(
'ws://localhost:4001/graphql',
{}
);
const client = createClient({
url: 'http://localhost:4000/graphql',
exchanges: [
debugExchange,
cacheExchange,
fetchExchange,
subscriptionExchange({
forwardSubscription: operation => subscriptionClient.request(operation),
}),
],
});
export const App: FC = () => (
<Provider value={client}>
<main>
<h1>New messages</h1>
<Messages />
</main>
</Provider>
);
App.displayName = 'App';
ReactDOM.render(<App />, document.getElementById('root'));