import { ApolloClient, InMemoryCache, ApolloLink } from '@apollo/client';
import { BatchHttpLink } from '@apollo/client/link/batch-http';
import { apolloCacheVoteablePossibleTypes } from '../../../lib/make_voteable';
import meteorAccountsLink from './links/meteor';
import errorLink from './links/error';

export const createApolloClient = () => {
  const cache = new InMemoryCache({
    possibleTypes: {
      ...apolloCacheVoteablePossibleTypes()
    }
  })
    .restore((window as any).__APOLLO_STATE__); //ssr
  
  const httpLink = new BatchHttpLink({
    uri: '/graphql',
    credentials: 'same-origin',
  });
  
  return new ApolloClient({
    link: ApolloLink.from([errorLink, meteorAccountsLink, httpLink]),
    cache
  });
};

import { ApolloClient, InMemoryCache, ApolloLink } from '@apollo/client';
import { BatchHttpLink } from '@apollo/client/link/batch-http';
import { apolloCacheVoteablePossibleTypes } from '../../../lib/make_voteable';
import meteorAccountsLink from './links/meteor';
import errorLink from './links/error';

export const createApolloClient = () => {
  const cache = new InMemoryCache({
    possibleTypes: {
      ...apolloCacheVoteablePossibleTypes()
    }
  })
    .restore((window as any).__APOLLO_STATE__); //ssr
  
  const httpLink = new BatchHttpLink({
    uri: '/graphql',
    credentials: 'same-origin',
    batchMax: 50,
  });
  
  return new ApolloClient({
    link: ApolloLink.from([errorLink, meteorAccountsLink, httpLink]),
    cache
  });
};

Increase the maximum queries per batch in BatchHttpLink from 10 to 50
Increase the maximum queries per batch in BatchHttpLink from 10 to 50

In posts with a lot of Elicit predictions or hover-previewable links,
this prevents excessive http requests and rerenders (previously it would
make one http request for every 10).
