How to integrate Yoga server to Apollo Federation?

Hey team, we have a couple of graphQL developed with yoga, I wonder if you can help guide us on how we can convert those graphQL endpoints as a subgraph and configured to Apollo Federation. I did not find explicit document on this but it seems that we need to configure with Envelop and then use the Apollo plugin to configure with federation?

Appreciate any guidance!

Hello :wave:
graphql-yoga is fully compatible with Apollo Federation. You just need to add the dependency on @apollo/subgraph and then follow the steps defined in the docs (basically add the __resolveReference methods to the entities).

thank you! You are right. It worked!
A quick follow -up, if we want to convert a REST API into a subgraph, do I need to use datasources package?

We are working on making it simpler but currently in order to expose your REST APIs as a subgraph, you would need to expose it as a fully fledged GraphQL subgraph (and your resolvers would make downstream calls to your REST API).

Yes you would need to create a schema and within your resolvers you can call whatever APIs to ger your data (REST, gRPC, databases or whatever).

Note that while it might be useful to expose this downstream data directly in a GraphQL schema (i.e. provide 1:1 mapping), in many cases it might be beneficial to actually abstract away those sources of data and provide something that is more usable to the clients. TLDR is → I’d recommend to always design your schema with your clients needs.