Skip to content

Commit d590fdd

Browse files
committed
update subgrapgh url
1 parent 0fbb03e commit d590fdd

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

graphql/index.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1-
import { ApolloClient, InMemoryCache, HttpLink, split } from '@apollo/client';
1+
import { ApolloClient, InMemoryCache, HttpLink, split, ApolloLink } from '@apollo/client';
22
import { LOOPRING_SUBGRAPH, UNISWAP_SUBGRAPH } from '../utils/config';
33

44
const loopringLink = new HttpLink({
5-
uri: LOOPRING_SUBGRAPH,
5+
uri: LOOPRING_SUBGRAPH
6+
});
7+
8+
const mapBody = new ApolloLink((operation, forward) => {
9+
return forward(operation).map(response => {
10+
return {
11+
...response,
12+
data: {
13+
...response.data,
14+
// @ts-ignore
15+
...JSON.parse(response.data).data
16+
}
17+
}
18+
});
619
});
720

821
const uniswapLink = new HttpLink({
922
uri: UNISWAP_SUBGRAPH,
1023
});
1124

1225
const client = new ApolloClient({
13-
link: split((op) => op.getContext().protocol === 'uniswap', uniswapLink, loopringLink),
26+
link: split((op) => op.getContext().protocol === 'uniswap', uniswapLink, mapBody.concat(loopringLink)),
1427
cache: new InMemoryCache({
1528
typePolicies: {
1629
Query: {

utils/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// TODO: remove once env variables are added to vercel.
22
export const LOOPRING_SUBGRAPH =
33
process.env.NEXT_PUBLIC_SUBGRAPH_ENDPOINT ??
4-
'https://api.thegraph.com/subgraphs/name/loopring/loopring';
4+
'https://dev.loopring.io/api/v3/forwardRequest';
55
export const EXPLORER_URL = 'https://etherscan.io/';
66
export const INFURA_ENDPOINT =
77
process.env.NEXT_PUBLIC_INFURA_ENDPOINT ?? 'https://mainneteth.loopring.io';

0 commit comments

Comments
 (0)