The _join field
When using WunderGraph, you might notice that there's a _join
field added to all Object Types in your generated GraphQL Schemas.
The _join
field is a special field that allows you to embed Queries into the response of another Operation.
This way, you can "join" multiple heterogeneous APIs into a single response without adding custom resolvers.
Let's look at an example to illustrate this:
query ($code: ID! $capital: String! @internal) {# Get the country with the given codecountry: countries_country(code: $code){codenamecapital @export(as: "capital")# "join" a new Query to the returned country to fetch the weatherweather: _join {weather_getCityByName(name: $capital){weather {summary {titledescription}temperature {actual}}}}}}
First, we fetch the country with the given code. Then, we "join" a new Query to the returned country to fetch the weather.
If you look closer, you will notice that the _join
simply returns a new Query Type.
This way, we're able to make a second embedded Query.
You also see some more concepts in this example,
namely the @export
and @internal
directives.
If you want to learn more about them,
head over to the reference section on Directives.