Skip to Content

Configure OpenAPI (REST) DataSource

Published: September 09, 2021

WunderGraph allows you to use REST (OpenAPI) APIs and add them to your "virtual" GraphQL API. This works by introspecing the OpenAPI Specification, parsing it and turning it into a GraphQL API on the fly. WunderGraph does this automatically, so don't worry about the process too much.

All you have to do is point the introspection to the yaml or json file containing the OAS. Once you have it introspected, pass it to the Application and you're good to go.

const jsonPlaceholder = introspect.openApi({
source: {
kind: "file",
filePath: "jsonplaceholder.v1.yaml",
}
});
const openAPI = introspect.openApi({
source: {
kind: "file",
filePath: "users_oas.json"
},
headers: {
// You're able to pass headers to the API, e.g. an API key
"Authorization": "token"
}
});

Once the configuration is updated, you're able to Query your REST API using GraphQL, how cool is that!?


Product

Subscribe to our newsletter!

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

© 2021 WunderGraph