Minor app improvements.

This commit is contained in:
Patrick Fic
2025-03-06 15:00:44 -08:00
parent 981012f20e
commit 45ed6f7804
10 changed files with 138 additions and 94 deletions

View File

@@ -1,43 +1,14 @@
//GQL Imports
import {
ApolloClient,
from,
HttpLink,
InMemoryCache,
split,
} from "@apollo/client";
import { ApolloClient, from, HttpLink, InMemoryCache } from "@apollo/client";
import { setContext } from "@apollo/client/link/context";
import { onError } from "@apollo/client/link/error";
import { RetryLink } from "@apollo/client/link/retry";
//import { WebSocketLink } from "@apollo/client/link/ws";
import { getMainDefinition } from "@apollo/client/utilities";
import { auth } from "../firebase/firebase.utils";
import env from "../env";
import { auth } from "../firebase/firebase.utils";
const httpLink = new HttpLink({
// uri: "https://bodyshop-dev-db.herokuapp.com/v1/graphql",
uri: env.uri,
});
// const wsLink = new WebSocketLink({
// //uri: "wss://bodyshop-dev-db.herokuapp.com/v1/graphql",
// uri: "wss://db.imex.online/v1/graphql",
// options: {
// lazy: true,
// reconnect: true,
// connectionParams: async () => {
// const token =
// auth.currentUser && (await auth.currentUser.getIdToken(true));
// if (token) {
// return {
// headers: {
// authorization: token ? `Bearer ${token}` : "",
// },
// };
// }
// },
// },
// });
//https://stackoverflow.com/questions/57163454/refreshing-a-token-with-apollo-client-firebase-auth
const errorLink = onError(
@@ -113,13 +84,6 @@ const retryLink = new RetryLink({
},
});
// const middlewares = [];
// if (process.env.NODE_ENV === "development") {
// middlewares.push(apolloLogger);
// }
// middlewares.push(retryLink.concat(errorLink.concat(authLink.concat(link))));
const cache = new InMemoryCache({});
export const client = new ApolloClient({
@@ -128,8 +92,6 @@ export const client = new ApolloClient({
link: from([authLink, retryLink, errorLink, httpLink]),
cache,
notifyOnNetworkStatusChange: true,
// connectToDevTools: process.env.NODE_ENV !== "production",
defaultOptions: {
watchQuery: {
fetchPolicy: "network-only",