GraphQL for intra service communication


Right now there’s many examples as the client being the “front-end app”, however, I’m curious about the context of a “back-end client” that talks to the Apollo/GraphQL server for the same/similar concerns. If you don’t do this then you have to create BOTH a rest endpoint and GraphQL entryway for a particular piece of functionality.

Is this not the right shape for GraphQL or a great way to communicate consistently without duplicating code?


That’s definitely an open question in my mind. On the one hand, GraphQL is unashamedly focused on the needs of UI developers. On the other hand, having a strongly typed API between your services sounds pretty good!

I feel like if you have an external API, you’ll probably want both REST and GraphQL, but I think it’s very easy to make that happen with no code duplication - you expose some ways to get individual objects from your backend, and then also use those functions in your GraphQL resolvers.


Would you see those additional REST endpoints at an “API Gateway” that the GraphQL server resolves from?

Yeah, as you said, would have a nice strongly typed API between services.


Yeah exactly. But like I said I’m not sure yet.


I have just changed a Meteor app that communicates to an external GraphQL API service, to use the apollo-client instead. So my back-end is the client requesting data from a GQL server.

That was pretty easy as apollo’s client is practically a 1-1 replacement for the graphql-js client.
The only thing of note was that I had to install a fetch package (e.g. node-fetch), as apollo depends on it but doesn’t ship with one. That wasn’t documented at the time (it is now).
Other than that, it worked just like you’d expect on the front-end.

I haven’t implemented authentication yet as this whole communication happens behind a closed firewall anyway, but I’ll try the now documented approach for this as well.


I’d love to read more about this! If you’re inclined it would be cool to talk about the pros and cons of switching to apollo client, or just your experience using GraphQL, in a blog post!


Yea I was thinking about writing a Medium post about using GraphQL for my little API service which uses Sequelize to interact with the legacy MSSQL and syncs with my Meteor’s mongo (non-reactively).
But then you guys published your example app doing most of that, but much better with Apollo.

So I think I’d like to change the GQL service to Apollo first and then look at making that sync process more reactive if possible.
But yea, that should be good stuff for a little post.


I’d be happy to feature it on the Apollo Medium publication if you’d be interested!


I’d be extremely interested in reading, and learning from that experience @batjko – please, please :slight_smile:


Ok, I’ll see if I can cobble something together then.