Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

Share apollo client instance (#5693)

authored by yoginth.com and committed by

GitHub 73922fae 1bc84912

+8 -6
+1 -1
apps/api/src/routes/og/getAccount.ts
··· 19 19 return ctx.html(cachedAccount, 200); 20 20 } 21 21 22 - const { data } = await apolloClient().query({ 22 + const { data } = await apolloClient.query({ 23 23 query: AccountDocument, 24 24 variables: { request: { username: { localName: username } } }, 25 25 fetchPolicy: "no-cache"
+1 -1
apps/api/src/routes/og/getGroup.ts
··· 18 18 return ctx.html(cachedGroup, 200); 19 19 } 20 20 21 - const { data } = await apolloClient().query({ 21 + const { data } = await apolloClient.query({ 22 22 query: GroupDocument, 23 23 variables: { request: { group: address } }, 24 24 fetchPolicy: "no-cache"
+1 -1
apps/api/src/routes/og/getPost.ts
··· 19 19 return ctx.html(cachedPost, 200); 20 20 } 21 21 22 - const { data } = await apolloClient().query({ 22 + const { data } = await apolloClient.query({ 23 23 query: PostDocument, 24 24 variables: { request: { post: slug } }, 25 25 fetchPolicy: "no-cache"
+2 -2
apps/web/src/components/Common/Providers/index.tsx
··· 1 1 import authLink from "@/helpers/authLink"; 2 2 import { ThemeProvider } from "@/hooks/useTheme"; 3 3 import { ApolloProvider } from "@apollo/client"; 4 - import apolloClient from "@hey/indexer/apollo/client"; 4 + import { createApolloClient } from "@hey/indexer/apollo/client"; 5 5 import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; 6 6 import type { ReactNode } from "react"; 7 7 import ErrorBoundary from "../ErrorBoundary"; ··· 12 12 defaultOptions: { queries: { refetchOnWindowFocus: false } } 13 13 }); 14 14 15 - const lensApolloClient = apolloClient(authLink); 15 + const lensApolloClient = createApolloClient(authLink); 16 16 17 17 interface ProvidersProps { 18 18 children: ReactNode;
+3 -1
packages/indexer/apollo/client.ts
··· 4 4 import httpLink from "./httpLink"; 5 5 import retryLink from "./retryLink"; 6 6 7 - const apolloClient = (authLink?: ApolloLink) => 7 + export const createApolloClient = (authLink?: ApolloLink) => 8 8 new ApolloClient({ 9 9 cache, 10 10 connectToDevTools: true, ··· 12 12 ? from([authLink, retryLink, httpLink]) 13 13 : from([retryLink, httpLink]) 14 14 }); 15 + 16 + const apolloClient = createApolloClient(); 15 17 16 18 export default apolloClient;