Skip to Content

Virtual Graph

Published: 2022-05-23

When you browse through the docs of WunderGraph or watch one of our videos, you will keep us mentioning the concept of a Virtual Graph. Let's briefly explain what we mean by this term.

Let's say, you're building an application that makes use of two APIs, a countries and a weather API.

The configuration might look like this:

const countries = integrations.wundergraph.countries({
apiNamespace: "countries",
});
const weather = integrations.wundergraph.weather({
apiNamespace: "weather",
});
const myApplication = new Application({
name: "app",
apis: [
countries,
weather,
],
});

We've added the countries and weather APIs from the WunderHub so that we don't have to introspect them again. Then, we're adding both APIs to our application.

If we now run wunderctl generate, both APIs will be combined into a single Virtual Graph. This Virtual Graph is a GraphQL schema that contains all fields and types from both APIs. As we're using the namespacing feature, both APIs live in their own namespace, but still in the same GraphQL Schema.

Combining both APIs into a single Virtual Graph allows you to _join data from both APIs.

A virtual Graph is unique to each WunderGraph application.

Why Virtual?#

You might ask why we're calling it a Virtual Graph. That's simply because this GraphQL API only exists virtually. Once the Application is deployed, all Operations are persisted and turned into a REST API. The GraphQL API is not visible to the public world, it's only a means to allow you to define your API Operations in a very user-friendly way.


Product

Comparisons

Subscribe to our newsletter!

Stay informed when great things happen! Get the latest news about APIs, GraphQL and more straight into your mailbox.

© 2022 WunderGraph