Skip to content

hasura/ndc-open-api-lambda

Repository files navigation

OpenAPI Lambda Connector

Docs ndc-hub License

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

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

  1. Create a Hasura Cloud account
  2. Please ensure you have the DDN CLI and Docker installed
  3. Create a supergraph
  4. Create a subgraph
  5. 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.

Known Limiations

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.