UNPKG

ra-data-graphql

Version:

A GraphQL data provider for react-admin

30 lines (26 loc) 633 B
import { ApolloClient, ApolloClientOptions, HttpLink, InMemoryCache, } from '@apollo/client'; export default (options?: Partial<ApolloClientOptions<unknown>>) => { if (!options) { return new ApolloClient({ cache: new InMemoryCache().restore({}), }); } const { cache = new InMemoryCache().restore({}), uri, credentials, headers, link = uri ? new HttpLink({ uri, credentials, headers }) : undefined, ...otherOptions } = options; return new ApolloClient({ link, cache, ...otherOptions, }); };