Skip to content

hasura/ndc-python-lambda

Repository files navigation

Hasura Python Lambda Connector

Docs ndc-hub License Status

This connector allows you to write Python code and call it using Hasura!

With Hasura, you can integrate -- and even host -- this business logic directly with Hasura DDN and your API.

You can handle custom business logic using the Python Lambda data connector. Using this connector, you can transform or enrich data before it reaches your customers, or perform any other business logic you may need.

You can then integrate these functions as individual commands in your metadata and API. This process enables you to simplify client applications and speed up your backend development!

This connector is built using the Python Data Connector SDK and implements the Data Connector Spec.

Before you get Started

  1. The DDN CLI and Docker installed
  2. A supergraph
  3. A subgraph

The steps below explain how to Initialize and configure a connector for local development. You can learn how to deploy a connector — after it's been configured — here.

Using the Python 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 python -i

Step 2.1: Choose the hasura/python option 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 3: Introspect the connector

Introspecting the connector will generate a config.json file and a python.hml file.

ddn connector introspect python

Step 4: Add your resources

You can add the models, commands, and relationships to your API by tracking them which generates the HML files.

ddn connector-link add-resources python

Step 5: Run your connector

You can run your connector locally, or include it in the docker setup.

Run the connector in Docker

To include your connector in the docker setup, include its compose file at the top of your supergraph compose.yaml file like this:

include:
  - path: app/connector/python/compose.yaml

Run the connector locally

To run your connector outside of Docker first go into the connector directory:

cd app/connector/python

Install the requirements:

pip3 install -r requirements.txt

Then run the connector locally:

ddn connector setenv --connector connector.yaml -- python3 functions.py serve

Documentation

View the full documentation for the Python Lambda connector here.

Contributing

Check out our contributing guide for more details.

License

The Turso connector is available under the Apache License 2.0.