Skip to Content

API Namespacing

Published: 2022-05-23

What happens if you combine the fields and types from two or more APIs into a single GraphQL Schema?

It's very likely that there will be naming collisions between the APIs, as they were not designed to be used with other APIs in the same schema.

One of the core values of WunderGraph is to make collaboration with APIs as easy as possible. To enable this, we've developed WunderHub, the Package Manager for APIs.

One of the key features of WunderHub is that you can import APIs with a single command. E.g. you simply run wunderctl add wundergraph/countries wundergraph/weather and you're ready to use the two APIs like below.

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

Without putting each API in its own namespace, there would be a chance to have naming collisions between the APIs.

Naming collisions in this case would mean that we would not be able to automatically merge the APIs into a Virtual Graph. Having to manually rename field and type names would be a pain and result in an unpleasant developer experience.

That's why we've added API Namespacing. API Namespacing allows you to specify a namespace for each API. Upon creation of the Virtual Graph, all APIs will be put into their own "namespace", eliminating the chance of naming collisions. No manual renaming is required.


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