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