Android Kotlin project with multiple Apollo clients hitting the same endpoint

We’ve implemented gql into our app a while back that was meant to serve a new system. Now recently, other teams here have begun to use this backend service but the client devs have chosen to create new Apollo client instances rather than reusing the existing original client (at runtime we have three Apollo clients atm). Each of these clients addresses the same endpoint.

I’m sure that folks have reasons which might include how the client cache is managed, but I’m questioning this approach.

Is there guidance for or against multiple clients in a single app?

Hi!

Indeed when consuming the same API, it would make sense to share the same ApolloClient. In particular if you are using the normalized (or http) cache, this will help with caching.

If you still need separate instances, and using the cache, make sure to configure the caches to use distinct files to avoid conflicts.

It will also save memory to have only 1 client.