Baseline Expo52 and Dev Version

This commit is contained in:
Patrick Fic
2025-02-12 10:05:12 -08:00
parent 486332aae6
commit 23fdb02375
6 changed files with 2548 additions and 1885 deletions

View File

@@ -9,7 +9,7 @@ import {
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 { WebSocketLink } from "@apollo/client/link/ws";
import { getMainDefinition } from "@apollo/client/utilities";
import { auth } from "../firebase/firebase.utils";
import env from "../env";
@@ -18,25 +18,25 @@ const httpLink = new HttpLink({
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}` : "",
},
};
}
},
},
});
// 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
@@ -61,27 +61,27 @@ const subscriptionMiddleware = {
next();
},
};
wsLink.subscriptionClient.use([subscriptionMiddleware]);
//wsLink.subscriptionClient.use([subscriptionMiddleware]);
const link = split(
// split based on operation type
({ query }) => {
const definition = getMainDefinition(query);
// console.log(
// "##Intercepted GQL Transaction : " +
// definition.operation +
// "|" +
// // definition.name.value +
// "##"
// );
return (
definition.kind === "OperationDefinition" &&
definition.operation === "subscription"
);
},
wsLink,
httpLink
);
// const link = split(
// // split based on operation type
// ({ query }) => {
// const definition = getMainDefinition(query);
// // console.log(
// // "##Intercepted GQL Transaction : " +
// // definition.operation +
// // "|" +
// // // definition.name.value +
// // "##"
// // );
// return (
// definition.kind === "OperationDefinition" &&
// definition.operation === "subscription"
// );
// },
// wsLink,
// httpLink
// );
const authLink = setContext((_, { headers }) => {
return (
@@ -125,7 +125,7 @@ const cache = new InMemoryCache({});
export const client = new ApolloClient({
//link: ApolloLink.from(middlewares),
//link: from([apolloLogger, errorLink, authLink, link]),
link: from([authLink, link]),
link: from([authLink, retryLink, errorLink, httpLink]),
cache,
notifyOnNetworkStatusChange: true,