How to use multiple servers for our Application?

Hi Apollo team, our backend is going to use different instances of servers for each module of our app. Is there a chance to support multiple server urls for a single app. We are using the android and ios version of your SDK.

Just to be clear here is an example:
module-one-api.com/graphql
module-two-api.com/graphql

how could one app call queries on either of the server urls.

We have successfully used the library when using one server.

Thank you.

Hi @cbayarcal - each instance of ApolloClient in apollo-ios can only communicate with a single server. You could create more than one instance of ApolloClient with each connecting to a different server but I think that’s going to introduce other problems, probably with the caching layer.

You should consider using federation:

This will allow you to build a gateway. Gateway is basically a layer on top of your apps.

The first advantage is that now you will have a single endpoint handled by a single client. So it removes all your problems.

Second - you only have to expose the gateway to external traffic. That always helps.

Third - the gateway can handle stuff like user authentication. This way you don’t need to validate users in each app. You can just trust the gateway.

Fourth - you can have cache logic that is on top of all apps.

1 Like