Building a Unified API Using GraphQL Joins

GraphQL Joins lets developers join data from two different GraphQL services to create a unified GraphQL API without needing to write custom code or modify any underlying APIs. It enables you to quickly fetch data from across databases and other GraphQL services as if they were one schema to easily mix and match your data sources. 

To create a join, you need to define the relationship between the two data sets you want to unify. Joins are typically based on a shared key between the two objects, such as an ID or name. Once the relationship is established, the query returns both data sets, allowing us to ask complex questions and receive a wealth of information in one response.

Creating a Unified API in GraphQL

What is Unified API?

A unified API is a single place to get all your data. It is one API that acts as an orchestration layer to fetch all downstream APIs. The benefit of this for consumers is that there is only one endpoint to integrate with, and get all the data they need from a single place.

To give an analogy, think of shopping for groceries. The things you need when shopping are things like food, flowers, stationary, etc. There are specific stores that specialize in all these things - such as Trader Joe's for food, Home Depot for flowers, Office Depot for stationery. These stores may be spread out throughout the city, so you will end up making separate trips for each of those items. If you want to optimize, you could go to one single shopping complex and aim to hit all stores in that parking lot. Or you could do yourself multiple trips and go to one store that sells all these items: Target.