kat/add-apollo-timeout (#128)
Reviewed-on: railbird/railbird-mobile#128 Reviewed-by: Ivan Malison <ivanmalison@gmail.com>
This commit is contained in:
parent
d400434e89
commit
edff79abb6
@ -33,6 +33,7 @@
|
|||||||
"@types/react": "~18.2.14",
|
"@types/react": "~18.2.14",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
||||||
"@typescript-eslint/parser": "^6.17.0",
|
"@typescript-eslint/parser": "^6.17.0",
|
||||||
|
"apollo-link-timeout": "^4.0.0",
|
||||||
"babel-plugin-inline-dotenv": "^1.7.0",
|
"babel-plugin-inline-dotenv": "^1.7.0",
|
||||||
"backoff": "^2.5.0",
|
"backoff": "^2.5.0",
|
||||||
"d3-path": "^3.1.0",
|
"d3-path": "^3.1.0",
|
||||||
|
@ -7,6 +7,8 @@ import {
|
|||||||
from,
|
from,
|
||||||
} from "@apollo/client";
|
} from "@apollo/client";
|
||||||
|
|
||||||
|
import ApolloLinkTimeout from "apollo-link-timeout";
|
||||||
|
|
||||||
import React, {
|
import React, {
|
||||||
ReactNode,
|
ReactNode,
|
||||||
createContext,
|
createContext,
|
||||||
@ -61,15 +63,15 @@ export const ClientProvider: React.FC<Props> = ({ children }) => {
|
|||||||
return forward(operation);
|
return forward(operation);
|
||||||
});
|
});
|
||||||
|
|
||||||
// We use useMemo to avoid recreating the client on every render
|
var timeoutLink = new ApolloLinkTimeout(4000);
|
||||||
|
|
||||||
const client = useMemo(
|
const client = useMemo(
|
||||||
() =>
|
() =>
|
||||||
new ApolloClient({
|
new ApolloClient({
|
||||||
// Chain the middleware with the httpLink
|
link: from([authMiddleware, timeoutLink]).concat(httpLink),
|
||||||
link: from([authMiddleware, httpLink]),
|
|
||||||
cache: new InMemoryCache(),
|
cache: new InMemoryCache(),
|
||||||
}),
|
}),
|
||||||
[authHeader],
|
[authHeader], // Assuming authHeader is used within authMiddleware
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -3989,6 +3989,11 @@ anymatch@^3.0.3:
|
|||||||
normalize-path "^3.0.0"
|
normalize-path "^3.0.0"
|
||||||
picomatch "^2.0.4"
|
picomatch "^2.0.4"
|
||||||
|
|
||||||
|
apollo-link-timeout@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/apollo-link-timeout/-/apollo-link-timeout-4.0.0.tgz#3e255bcced6a6babdcc080b1919dd958c036e235"
|
||||||
|
integrity sha512-2tZsNvmbsAHunWSsGi+URLMQSDoSU0NRDJeYicX/eB7J94QXydgvZOG4FCsgU5hY0dhUrPrLCotcpJjvOOfSlA==
|
||||||
|
|
||||||
appdirsjs@^1.2.4:
|
appdirsjs@^1.2.4:
|
||||||
version "1.2.7"
|
version "1.2.7"
|
||||||
resolved "https://registry.yarnpkg.com/appdirsjs/-/appdirsjs-1.2.7.tgz#50b4b7948a26ba6090d4aede2ae2dc2b051be3b3"
|
resolved "https://registry.yarnpkg.com/appdirsjs/-/appdirsjs-1.2.7.tgz#50b4b7948a26ba6090d4aede2ae2dc2b051be3b3"
|
||||||
|
Loading…
Reference in New Issue
Block a user