Multiple ApolloServers needed to implement a gateway connecting to REST APIs?

552 views Asked by At

I'm building a graphql gateway service, which merge multiple services into one graph, using Apollo/Node/Express and following the Apollo Federation model. Initially, most of the services I'll be connecting to are REST services.

In all of the examples I find (e.g. here), I see that the gateway project runs multiple instances of ApolloServer, one for every REST service plus one more for the gateway itself, and runs them all using a package like concurrently. Basically the gateway project runs n+1 ApolloServers. Having all of these servers running seems strange to me, but I'm pretty new to this whole ecosystem.

I'm not clear if this is just for demonstration purposes, or is this also how it's implemented and deployed in the real world?

1

There are 1 answers

1
Dan Crews On

I hope that those were just examples, and are not the expected pattern.

If you need multiple GraphQL Services, each one of those would be served as a separate Domain Graph application, as its own project. Then an additional service (the gateway) would consume all of those applications and expose a single unified GraphQL API.