OpenAPI Lambda Connector
The OpenAPI Lambda Connector allows you to import APIs that are documented in the OpenAPI/Swagger format into the Hasura Supergraph. The connector exposes REST API endpoints as Typescript functions, which can be exposed as GraphQL queries or mutations via the NodeJS Lambda Connector.
Functions that wrap GET requests are marked with a @readonly
annotation, and are exposed as GraphQL Queries by the NodeJS Lambda Connector. All other request types are exposed as GraphQL Mutations.
This Connector implements the Data Connector Spec
- See the listing in the Hasura Hub
- Hasura DDN Documentation
- Hasura DDN Quickstart
- NodeJS Lambda Connector
Docs for the OpenAPI data connector:
Features
- Convert Open API/swagger documentation into Typescript functions compatible with NodeJS Lambda Connector
- Supported request types
Request Type | Query | Path | Body | Headers |
---|---|---|---|---|
GET | ✅ | ✅ | NA | ✅ |
POST | ✅ | ✅ | ✅ | ✅ |
DELETE | ✅ | ✅ | ✅ | ✅ |
PUT | ✅ | ✅ | ✅ | ✅ |
PATCH | ✅ | ✅ | ✅ | ✅ |
Before you get Started
- Create a Hasura Cloud account
- Please ensure you have the DDN CLI and Docker installed
- Create a supergraph
- Create a subgraph
- If you want to make changes to the generated Typescript files, please ensure you have Node.js v20+ installed
Using the OpenAPI connector
Step 1: Authenticate your CLI session
ddn auth login
Step 2: Configure the connector
Once you have an initialized supergraph and subgraph, run the initialization command in interactive mode while providing a name for the connector in the prompt:
ddn connector init <connector-name> -i
Step 2.1: Choose hasura/openapi
from the list
Step 2.2: Choose a port for the connector
The CLI will ask for a specific port to run the connector on. Choose a port that is not already in use or use the default suggested port.
Step 2.3: Provide the env vars required for the connector
Environment variables that can be used to configure the connector are listed under Supported Environment Variables.
Step 3: Introspect the connector
ddn connector introspect <connector-name>
This will generate the required metadata and TypeScript files.
Step 4: Add your resources
ddn connector-link add-resources <connector-name>
This command will track all the API endpoints in your OpenAPI Document as Commands.
Saving User Changes
Please refer to Saving User Changes.
Known Limiations
- Support for Relaxed Types is a WiP.
- Types not supported by the NodeJS Lambda Connector are not supported.
Contributing
Check out our contributing guide for more details.
Changelog
Please refer to the changelog.
License
The Open API Lambda Connector is available under the Apache License 2.0.