Features
Cross-API Joins to Compose APIs
Imagine you'd like to access Data from multiple APIs and combine the results into a single dataset. WunderGraph supports a rich set of DataSources, so we wanted to add a simple way to achieve JOINs across APIs.
Example: Joining Capitals with Weather Data
Let's say we want to get the weather data for all capitals of a continent. You'd probably want to add two APIs to your application, one to query the capitals and the other to query the weather data.
Next, let's define our JOIN query.
The response looks like this:
The "Magic" behind the JOIN
WunderGraph first queries the countries API to get all the countries of a continent. Then, it queries the weather API for each capital of the countries.
We're using the @export
directive to export the value of the field capital
into the JOIN key ($capital). Then we're using the _join
field to join the weather API.
The _join
field is a special field that exists on every object type. It simply returns the Query type, so you can join a response of one API with another.
Reference Documentation
If you want to learn more about how JOINs work, you can read the reference docs on the @export
directive, the @internal
directive, as well as the _join
field.