OpenAPI Connector

OpenAPI Connector

Grafbase now supports connecting REST APIs using OpenAPI!

Developers today are using plethora of data sources to build applications for the web and mobile.

Data no longer lives or belongs to only one source, but is often enhanced, indexed and retrieved across many service APIs and protocols.

From today, you can now unify your existing REST APIs at the edge with GraphQL.

Grafbase is on a mission to unify the data layer with its globally deployed Edge Gateway.

Let's see how easy it is to add Stripe, OpenAI and GitHub, using the new @openapi connector:

extend schema @openapi( name: "Stripe" schema: "https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json" headers: [ { name: "Authorization", value: "Bearer {{ env.STRIPE_API_KEY }}" } ] ) { query: Query }

That's it! That's all you need to do to add an external data source to Grafbase using connectors.

Grafbase automatically generates all queries and mutations from the OpenAPI schema specification that you provided to the @openapi directive.

The queries and mutations are namespaced as a query field using the name you provided in the configuration.

query { stripe { invoices { nodes { id amountDue amountPaid created customerName customerEmail } } } }

Grafbase also makes it easy to connect multiple APIs. Simply add another @openapi directive:

extend schema @openapi( name: "Stripe" schema: "https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json" headers: [ { name: "Authorization", value: "Bearer {{ env.STRIPE_API_KEY }}" } ] ) @openapi( name: "OpenAI" schema: "https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml" headers: [ { name: "Authorization", value: "Bearer {{ env.OPENAI_API_KEY }}" } ] ) { query: Query }

As always, you can build locally using the Grafbase CLI.

npx grafbase init --template openapi-stripe

You can dive deeper with connectors by exploring the documentation.

Youtube video thumbnail

We'd love to hear your feedback and ideas, so join us on Discord.