import { ApolloClient, ApolloLink, HttpLink, InMemoryCache, NormalizedCacheObject, } from '@apollo/client/core'; import fetch from 'cross-fetch'; export const getGqlClient = ( endpoint: string, accessToken?: string, ): ApolloClient => { return new ApolloClient({ link: ApolloLink.from([ new HttpLink({ uri: endpoint, headers: { ...(accessToken ? { authorization: `Bearer ${accessToken}` } : {}), }, fetch, }), ]), cache: new InMemoryCache(), }); };