This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Burtey
committed
Aug 23, 2023
1 parent
0e9a9e8
commit 6d3a89d
Showing
7 changed files
with
58 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { | ||
ApolloClient, | ||
ApolloLink, | ||
concat, | ||
gql, | ||
HttpLink, | ||
InMemoryCache, | ||
} from "@apollo/client" | ||
|
||
import { GRAPHQL_URL_INTERNAL } from "../../../lib/config" | ||
|
||
const ipForwardingMiddleware = new ApolloLink((operation, forward) => { | ||
operation.setContext(({ headers = {} }) => ({ | ||
headers: { | ||
...headers, | ||
"x-real-ip": operation.getContext()["x-real-ip"], | ||
"x-forwarded-for": operation.getContext()["x-forwarded-for"], | ||
}, | ||
})) | ||
|
||
return forward(operation) | ||
}) | ||
|
||
export const client = new ApolloClient({ | ||
link: concat( | ||
ipForwardingMiddleware, | ||
new HttpLink({ | ||
uri: GRAPHQL_URL_INTERNAL, | ||
fetchOptions: { cache: "no-store" }, | ||
}), | ||
), | ||
cache: new InMemoryCache(), | ||
}) | ||
|
||
gql` | ||
query accountDefaultWallet($username: Username!, $walletCurrency: WalletCurrency!) { | ||
accountDefaultWallet(username: $username, walletCurrency: $walletCurrency) { | ||
__typename | ||
id | ||
walletCurrency | ||
} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters