Gateway for graphql API that doesnt support federation

Hi folks!
I am new to the Apollo ecosystem but in short, how to make Apollo the gateway to another GrapqhQL not supporting federation?

We have a GraphQL written with graphql-go which is becoming unmanageable. We want to move away from it and decided to opt for Apollo.
I was thinking that the first step would be as simple as putting the Apollo gateway in front of our server but I think I was wrong. It doesn’t support Apollo Federation

What would be the most simple way to put in Apollo in front of it so we can start rewrite this GrapqhlQL API into proper subgraphs?

As a sidenote we are planning to go for the full Apollo experience (studio, schema registry, …), not just the open source framework.

1 Like

Presently, the Gateway requires an underlying implementation that supports the Federated specification. This is because Federation requires knowledge of entities to be able to query plan across multiple subgraphs (your Go server being one of those subgraphs). Other Go GraphQL projects (and many non-Go implementations!) do support Federation, like gqlgen, but otherwise it appears that the graphql-go project is tracking the feature request to add Federation support in this issue.

If there is exactly one service in your federated graph and it doesn’t support Federation, it’s plausible to believe that you could put the Apollo Gateway in front of it and it could work but that would not be a recommended configuration and it would probably require additional hoops to be jumped through.

Is it conceivable that you might be able to first transition to using gqlgen rather than graphql-go? That might be a good next step, though I’m not making any claims about the simplicity of doing so as I’m not familiar with the implementations in either one!

1 Like

This would be a fair amount of work. gqlgen is schema first while graphql-go is code-first, so the code structure would be quite different.

Thanks for your help, Ill keep exploring. That being said that’s a major set back for us to adopt apollo :frowning:

FWIW, “support federation” isn’t that hard. You need to make { _service { sdl } } return the text of your schema, and you need to implement a Query._entities resolver. And you need to add the definitions of the directives to your schema. You could probably just do it in your app!

1 Like

That’s definitely worth exploring

In that case, I’d suggest going with what @glasser is hinting at and try just making federation work. The federated specification explains the details, and there are several reference implementations.

Not sure how contributions are accepted to graphql-go, there’s perhaps just an opportunity for you to implement this upstream in that implementation. Within your app seems like a great way to unblock yourselves quickly though!

1 Like

I managed to make it work in a very simple way,
I just implemented _service field and that made Apollo gateway happy.

I won’t ever need to join this schema with anything, so I guess I won’t ever need to implement _entities or any directives?

Too easy, thanks for the great advices