Kris Yotamrevised entire site1a92d151 year agoHistory
35 lines · 890 B · TypeScript
RawDownload
"use client" import type React from "react" import { ApolloClient, ApolloProvider, InMemoryCache, HttpLink } from "@apollo/client"import { useMemo } from "react" export function ApolloWrapper({ children }: { children: React.ReactNode }) {  const client = useMemo(() => {    const token = process.env.NEXT_PUBLIC_LITERAL_API_TOKEN || ""     return new ApolloClient({      link: new HttpLink({        uri: "https://literal.club/graphql/",        headers: {          authorization: token ? `Bearer ${token}` : "",        },      }),      cache: new InMemoryCache(),      defaultOptions: {        query: {          fetchPolicy: "no-cache",          errorPolicy: "all",        },        watchQuery: {          fetchPolicy: "no-cache",          errorPolicy: "all",        },      },    })  }, [])   return <ApolloProvider client={client}>{children}</ApolloProvider>}