Data source configuration
For this scenario, we need to introspect two APIs, a weather and a countries GraphQL API:
As you can see, we're using the
apiNamespace feature of WunderGraph to make sure that there are no naming conflicts between the APIs.
Configure the Operation
Next, let's configure the Operation.
This Operation uses the
_join field to embed a second Query (weather_getCityByName) into the result of the first Query (countries_countries).
@internal directive is used to mark the
$capital variable as an internal variable, which means that it will not be exported to the client.
During the execution of the Operation, the GraphQL engine will first resolve the
countries_countries Query. When resolving the
capital field, it will export the value into the
Then, the GraphQL engine will resolve the
weather_getCityByName Query using the
$capital variable. The result will be added to the result of the
countries_countries Query as a new field called
Finally, we're using the
@transform directive to flatten the result of the
weather_getCityByName Query, removing unnecessary nesting.
We've just combined two APIs without having to use any glue code. This Operation is a valid GraphQL Operation and can be defined in your IDE with full type safety.
Deploy to WunderGraph Cloud
The easiest way to deploy your WunderGraph app is to use WunderGraph Cloud.