-
Notifications
You must be signed in to change notification settings - Fork 0
/
urql.ts
45 lines (38 loc) · 1.41 KB
/
urql.ts
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
44
45
import {
cacheExchange,
createClient,
dedupExchange,
fetchExchange,
ssrExchange,
} from "urql";
// let client: Client;
// If we need subscriptions this is how to do it
// let wsClient: Client | undefined;
// if (typeof window !== 'undefined') {
// wsClient = createWSClient({
// url: 'ws://api.thegraph.com/subgraphs/id/QmZah3zzX8P6GAhFSgXJBs8cDrtXumLGXVutR9cmCEB4bJ',
// });
// }
// if (typeof window !== 'undefined') {
// const subscriptionClient = new SubscriptionClient('wss://api.thegraph.com/subgraphs/id/QmPF3iZqdKz4Nm7cSN9Rs8U2K8yJu8pKzuqRr8HtYWaF9u', { reconnect: true });
// client = createClient({
// url: 'https://api.thegraph.com/subgraphs/id/QmPF3iZqdKz4Nm7cSN9Rs8U2K8yJu8pKzuqRr8HtYWaF9u',
// exchanges: [
// ...defaultExchanges,
// subscriptionExchange({
// forwardSubscription: (operation) => subscriptionClient.request(operation)
// }),
// ],
// });
// } else {
// client = createClient({
// url: 'https://api.thegraph.com/subgraphs/id/QmPF3iZqdKz4Nm7cSN9Rs8U2K8yJu8pKzuqRr8HtYWaF9u',
// })
// }
const isServerSide = typeof window === "undefined";
export const ssrCache = ssrExchange({ isClient: !isServerSide });
const client = createClient({
url: "https://api.thegraph.com/subgraphs/name/vanilladefi/vanilla-chainlink-polygon-price-feed-v3-dev",
exchanges: [dedupExchange, cacheExchange, ssrCache, fetchExchange],
});
export default client;