Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createGraphQLClient({
server,
initialData,
graphQLEndpoint = '/graphql',
connectToDevTools,
headers = {},
}: Options) {
const cache = new InMemoryCache({
dataIdFromObject: object => object.id,
});
const link = createHttpLink({
credentials: 'include',
uri: graphQLEndpoint,
headers: {
[Header.Accept.toLowerCase()]: 'application/json',
[Header.ContentType.toLowerCase()]: 'application/json',
...headers,
},
});
return new ApolloClient({
link,
ssrMode: server,
ssrForceFetchDelay: 100,
cache: initialData ? cache.restore(initialData) : cache,
connectToDevTools: !server && connectToDevTools,
});
}