Skip to main content

Custom ApolloClient

Overview

By default, Apollo Orbit uses the default ApolloClient implementation provided by @apollo/client/core library.
But, it is possible in some scenarios that an application needs to provide its own custom implementation of ApolloClient.

This can be achieved by providing a custom ApolloClientFactory function to APOLLO_CLIENT_FACTORY injection token.

Usage

import { ApolloClientFactory } from '@apollo-orbit/angular';
import { CustomApolloClient } from 'custom-apollo-client';

const customApolloClientFactory: ApolloClientFactory = (options: ApolloClientOptions<NormalizedCacheObject>): ApolloClient<NormalizedCacheObject> => {
return new CustomApolloClient(options);
};

...

{
providers: [
{ provide: APOLLO_CLIENT_FACTORY, useValue: customApolloClientFactory }
]
}